Search code examples
flutterdartflutter-build

Flutter Android Build Stuck after Upgrading to Android V2


I am experiencing this issue when I am trying to run my app on an Android Emulator(API 31, Android 12) after upgrading to Android V2:

Normal Run gets Stuck here:

√  Built build\app\outputs\flutter-apk\app-debug.apk.
Installing build\app\outputs\flutter-apk\app.apk...
Error waiting for a debug connection: The log reader stopped unexpectedly
Error launching application on sdk gphone64 x86 64.

Running it with the flutter run --verbose gets stuck with the last output being:

[   +1 ms] Installing build\app\outputs\flutter-apk\app.apk... (completed in 4.5s)
[   +3 ms] executing: C:\Users\14166\AppData\Local\Android\sdk\platform-tools\adb.exe -s emulator-5554 shell echo -n 32cccba394c538fcf9ce787aea14716102705201 >
/data/local/tmp/sky.com.example.flutter_urban_state.sha1
[  +71 ms] executing: C:\Users\14166\AppData\Local\Android\sdk\platform-tools\adb.exe -s emulator-5554 shell -x logcat -v time -t 1
[ +315 ms] --------- beginning of main
                    02-24 07:38:41.859 E/.apps.wellbein( 7277): Not starting debugger since process cannot load the jdwp agent.
[  +15 ms] executing: C:\Users\14166\AppData\Local\Android\sdk\platform-tools\adb.exe -s emulator-5554 shell am start -a android.intent.action.RUN -f 0x20000000 --ez enable-dart-profiling true
--ez enable-checked-mode true --ez verify-entry-points true com.example.flutter_urban_state/com.example.flutter_urban_state.MainActivity
[+1065 ms] Starting: Intent { act=android.intent.action.RUN flg=0x20000000 cmp=com.example.flutter_urban_state/.MainActivity (has extras) }
[   +1 ms] Waiting for observatory port to be available...

Things I tried that did not work:

  • Clearing the build, cache, and deleting the outputs folder in build and restarting the app again
  • Made sure that the package names in AndroinManifest, and MainActivity.kt are exactly the same
  • Upgraded my Dart Version, Flutter Version, and All my pub packages
  • uninstalled my adb

Flutter doctor doesn't seem to show any errors either.


Solution

  • So after spending a lot of time I was able to fix the issue.

    What I did to fix it:

    • Changed the SDK version in the pubspec.yaml from sdk: ">=2.12.0 <3.0.0" to sdk: ">=2.16.1 <3.0.0"
    • In my AndroidManifest.Xml moved my manually added <meta-data.../> sections to be under the <application.../> tag, where as they were included under the <activity.../> tag before

    I really hope this answer is useful and will help someone!

    Cheers