Observatory server failed to start - Fails to create Socket Server

5,805

Solution 1

In Android Manifest file add Internet Permission. I'm also facing this problem. after adding this permission now working fine.

<uses-permission android:name="android.permission.INTERNET"/>

Problem is Internet permission is needed in release mode.

Android Manifest file have description for this

The INTERNET permission is required for development. Specifically, flutter needs it to communicate with the running application to allow setting breakpoints, to provide hot reload, etc.

Solution 2

Check android/app/src should have debug, main and profile directories. check image

  1. if debug folder is missing, just create one and copy manifest from profile, paste in debug.
  2. if debug folder is there check it is having internet permissions or not. if not add.

Solution 3

When I was stripping down the template I unknowingly removed the debug folder under android/app/src thinking it was files generated from the build. That's the manifest Android uses to allow debugging so it needs to be there.

Share:
5,805
Filled Stacks
Author by

Filled Stacks

I am a full time mobile applications developer working with Xamarin and MvvmCross to create applications for both iOS and Android. I also develop apps using Swift for iOS as well as Java for Android. I dabble in mobile games development (previous professional career) now I'm a fullstack app developer looking to make interesting apps and trying to help improve the mobile application space in any way possible.

Updated on December 10, 2022

Comments

  • Filled Stacks
    Filled Stacks over 1 year

    I'm building some internal tooling for myself to generate Flutter apps using some templates that I've setup along with some additional functionality that I can share between apps.

    At the moment the code compiles, builds fine and deploys but it gets stuck on the first view (blank white screen) and retries to start the Observatory server 11 times before failing. There are no other errors besides the one below.

    Launching lib\main.dart on Android SDK built for x86 in debug mode...
    Built build\app\outputs\apk\debug\app-debug.apk.
    I/flutter ( 7011): Observatory server failed to start after 1 tries
    I/flutter ( 7011): Observatory server failed to start after 2 tries
    I/flutter ( 7011): Observatory server failed to start after 3 tries
    I/flutter ( 7011): Observatory server failed to start after 4 tries
    I/flutter ( 7011): Observatory server failed to start after 5 tries
    I/flutter ( 7011): Observatory server failed to start after 6 tries
    I/flutter ( 7011): Observatory server failed to start after 7 tries
    I/flutter ( 7011): Observatory server failed to start after 8 tries
    I/flutter ( 7011): Observatory server failed to start after 9 tries
    I/flutter ( 7011): Observatory server failed to start after 10 tries
    I/flutter ( 7011): Observatory server failed to start after 11 tries
    I/flutter ( 7011): Could not start Observatory HTTP server:
    I/flutter ( 7011): SocketException: Failed to create server socket (OS Error: Permission denied, errno = 13), address = 127.0.0.1, port = 0
    I/flutter ( 7011): #0      _NativeSocket.bind (dart:io/runtime/bin/socket_patch.dart:591:7)
    I/flutter ( 7011): <asynchronous suspension>
    I/flutter ( 7011): #1      _RawServerSocket.bind (dart:io/runtime/bin/socket_patch.dart:1206:26)
    I/flutter ( 7011): #2      _ServerSocket.bind (dart:io/runtime/bin/socket_patch.dart:1466:29)
    I/flutter ( 7011): #3      ServerSocket.bind (dart:io/runtime/bin/socket_patch.dart:1457:26)
    I/flutter ( 7011): #4      _HttpServer.bind (dart:_http/http_impl.dart:2520:25)
    I/flutter ( 7011): #5      HttpServer.bind (dart:_http/http.dart:227:19)
    I/flutter ( 7011): #6      Server.startup.poll (dart:vmservice_io/server.dart:355:36)
    I/flutter ( 7011): <asynchronous suspension>
    I/flutter ( 7011): #7      Server.startup (dart:vmservice_io/server.dart:367:23)
    I/flutter ( 7011): <asynchronous suspension>
    I/flutter ( 7011): #8      main (dart:vmservice_io/vmservice_io.dart:253:12)
    I/flutter ( 7011): 
    

    My question's are:

    • how do I go about debugging this problem?
    • Do you have an idea of what can cause this?

    The code looks the same as the template I'm working off (that works) with the only difference being the package name is different.

    Edit 1

    Here is the link to the project that hangs for reproduction.

  • Günter Zöchbauer
    Günter Zöchbauer about 5 years
    The .gitignore file lists everything that can be dropped.
  • Aadn
    Aadn over 3 years
    this is so odd, I added this on my AndroidManifest.xml file and then I started getting this error. I read the documentation, currently the debug mode allows internet connection, but possibly in the release version people will need to give access. I am guessing that after adding this line I will be able to run this on my physical device, but not in Vitrual device for debug mode.
  • Nikhil Badyal
    Nikhil Badyal about 3 years
    just to make it clear. The answer is about DEBUG manifest and not the RELEASE manifest.