22

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.

Filled Stacks
  • 4,116
  • 1
  • 23
  • 36
  • Sounds like a firewall issue. Like you blocked the app creating network connections. What OS are you using? – Günter Zöchbauer Mar 12 '19 at 11:01
  • @GünterZöchbauer I'm using windows. All my other apps, including the template app this is based off, which can be found here https://github.com/FilledStacks/flutter-architecture-skeletons/tree/master/scoped_model_arc works perfectly fine. It's the version that is generated that's hanging on the first view. Are there any values in the flutter project that you know of that can cause this? I'm gonna upload some code for testing, maybe it is my machine. – Filled Stacks Mar 12 '19 at 11:43
  • Hard to tell. If it is related to the code, then try commenting out code in the page. Perhaps there is some endless loop or similar that doesn't allow the VM to respond in time. – Günter Zöchbauer Mar 12 '19 at 11:59
  • @GünterZöchbauer No code gets run. main.dart's first line is also not run. This is when starting the app in the debugging process, as soon as the app is deployed then I get the logs above. you can see it deploying and then trying to connect. Could you download my repo and try to run it, just want to confirm it's working/not working on someone else's machine. – Filled Stacks Mar 12 '19 at 12:04
  • @GünterZöchbauer code that's stalled is in the answer – Filled Stacks Mar 12 '19 at 12:05
  • @GünterZöchbauer I found the error. I removed the debug folder under android/app/src and it broke it. – Filled Stacks Mar 12 '19 at 12:38
  • I always get this when attempting to debug standard dart projects. I've never gotten this to work. I have dart installed via Flutter. > Dart VM version: 2.2.0-dev.0.0 (Mon Nov 19 15:10:42 2018 +0100) on > "macos_x64" – ThinkDigital May 19 '19 at 18:34

3 Answers3

31

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.

MSARKrish
  • 3,355
  • 4
  • 30
  • 43
  • 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. – Aadn Nov 07 '20 at 02:37
  • 2
    just to make it clear. The answer is about DEBUG manifest and not the RELEASE manifest. – Nikhil Badyal Apr 16 '21 at 11:42
11

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

enter image description here

  1. If debug folder is missing, just create one and copy manifest.xml from profile, paste in debug.

  2. If debug folder is there check it is having internet permissions or not. If not add.


On Flutter you would see in the android folder:

enter image description here

carloswm85
  • 1,396
  • 13
  • 23
techieasif
  • 153
  • 2
  • 9
4

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.

Filled Stacks
  • 4,116
  • 1
  • 23
  • 36