My new Flutter project is stuck in assembleGradle

I created a new project by running flutter create .. Then I modified the Android app's package by modifying it in:

  • android/app/build.gradle
  • android/app/src/main/AndroidManifest.xml

I also integrated Firestore to it, and added an Android app there, with the new package name.

Finally I ran it. It failed, complaining that android/app/src/debug/AndroidManifest.xml had the wrong app package. So I modified that file as well, and ran it again.

Now it built fine, but it got stuck in the assembleGradle step. I ended up on https://stackoverflow.com/questions/59516408/flutter-app-stuck-at-running-gradle-task-assembledebug. In some of the posters' cases, gradle downloaded at really low speed. I don't think it was the case for me, but I learned one thing. How to run it in verbose mode: flutter run -v.

So I did that and it turned out, the run was stuck at "Waiting for observatory port to be available". Another search got me to https://stackoverflow.com/questions/53830949/flutter-stuck-at-waiting-for-observatory-port-to-be-available-if-android-backg.

It turned out I had forgot to modify the package name in android/app/src/main/kotlin/com/example/cloud_firestore_mocks_test_app/MainActivity.kt. Seriously. I'd have expected a better error message than an infinite spinner.