skip to Main Content

I have an APK that is built in debug mode using flutter build apk --debug. I want to launch that APK using adb then connect to the dart VM service that is spun up.

I launch the application using:

adb -s emulator-5554 shell am start -n com.filledstacks.bookshelf/com.filledstacks.bookshelf.MainActivity

This works as expected and launches the app with the output:

Starting: Intent { cmp=com.filledstacks.bookshelf/.MainActivity }

I then use logCat to get the log for my Flutter application using the following shell command.

adb -s emulator-5554 logcat -d flutter:I '*:S' -T '09-20 16:24:48.967'

The command above filters logs for all flutter:I logs. This prints out what I expect:

--------- beginning of main
09-20 16:25:16.939 14663 14702 I flutter : The Dart VM service is listening on http://127.0.0.1:36659/Ex8iWuJ4xEo=/

But when I open that url I get the "site can’t be reached message".

My guess is that the process that launches the app is stopped, which shuts down the observatory. But I don’t have enough terminal experience to test that out. I’ve been trying for about 2 hours.

I’m on MacOS using latest adb.

2

Answers


  1. It seems like you’re doing the right thing, however, there might be an issue with the way you’re trying to connect to the Dart VM service.

    Follow these steps to troubleshoot the problem:

    1. Ensure that you’re trying to connect to the correct IP address and port. The URL you mentioned, "http://127.0.0.1:36659/Ex8iWuJ4xEo=/", should be accessible from your local machine where you’re running the adb command. If you’re trying to access it from another machine or emulator, you may need to use a different IP address.

    2. Check if your firewall or security settings are blocking the connection. Sometimes, security software can block connections to specific ports.

    3. Confirm that your Flutter app is indeed running and hasn’t crashed or exited. You can check this by running adb shell ps | grep your.package.name to see if the app’s process is still running.

    4. Ensure that your app is built with debugging support. You mentioned building the APK with flutter build apk –debug, which should include the necessary debug symbols.

    5. Try using the IP address of your emulator instead of "127.0.0.1." You can get the emulator’s IP address by running adb shell ifconfig and looking for the IP address associated with the emulator’s network interface.

    6. If you’re using a physical device, make sure it’s connected via USB and that USB debugging is enabled in developer options.

    7. Ensure that the emulator is fully booted and ready before attempting to connect to the Dart VM service.

    Login or Signup to reply.
  2. Try opening the URL by replacing 127.0.0.1 with 10.0.2.2
    This is the address for the emulator.

    OR

    You can port forward from the emulator to your host machine for accessing using 127.0.0.1.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search