Flutter stuck at 'waiting for observatory port to be available' if Android background services is used Flutter stuck at 'waiting for observatory port to be available' if Android background services is used dart dart

Flutter stuck at 'waiting for observatory port to be available' if Android background services is used


I had this problem and eventually tracked it down to the fact that I'd changed the package name of my project to com.test.MyAppName in the AndroidManifest. This is not a valid Dart package name. You can verify this by trying to create a new project using

flutter create --org com.test MyAppName

This results in the error message:

"MyAppName" is not a valid Dart package name.

From the Pubspec format description:

DO use lowercase_with_underscores for package names.

Package names should be all lowercase, with underscores to separate words, just_like_this. Use only basic Latin letters and Arabic digits: [a-z0-9_]. Also, make sure the name is a valid Dart identifier -- that it doesn't start with digits and isn't a reserved word.

The solution for me was to recreate my project with the desired values by running

flutter create --org com.test my_app_name

and copying across the lib folder, pubspec file, any assets, etc. This should fix the problem. Note that this results in the kotlin folder (android/app/main/kotlin) having subfolders set up correctly based on the domain that you specified, e.g. kotlin/com/test/ for com.test


I had the same problem. In my case flutter clean fixed the issue. The cause of problem for me was a rename in Android package. After renaming the package you might need to clean the flutter old build files.


If you're experiencing this and you use Firebase, try downloading and inserting a new copy of your "google-services.json" file from your Firebase console. Additionally, be sure you follow all of the steps listed in the Add Firebase to your Flutter App documentation.

If you have enabled Crashlytics for it as well, be sure you have enabled it in your Firebase console and have followed the other instructions listed in the Get Started with Firebase Crashlytics documentation.

I'm not exactly sure which one of these fixed my issue, but nothing else worked until I checked all steps listed in those two docs.