Observatory server failed to start - Fails to crea

2020-08-26 10:36发布

问题:

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.

回答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 debug 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.



回答2:

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.