Flutter is not able to install the apk into the real device suddenly

Problem

Uninstalling the app from the home page would cause subsequent flutter run commands to hang at the installing stage.

Running with flutter run -v showed that it installed successfully but the activity would not run when adb tried to run it.

Error output

The error message was class 3 ${packageName}/${packagName}.MainActivity not found.

Hacky fix

Changing the android app package name would cause it to work again until I uninstalled it manually from the phone.

Steps that did not work

  1. Rebooting the phone multiple times
  2. flutter clean didn’t work
  3. Restarting Android studio
  4. Restarting my computer
  5. Re-enabling USB debugging
  6. Revoking and authorizing my computer from USB debugging
  7. Re-enabling developer mode
  8. adb shell pm list package ${packageName} didn’t show it in the list so there was nothing to clean through there

Permanent fix

adb uninstall ${packageName} and it showed ‘Success’. Now subsequent flutter runs work perfectly.

Possible cause

It seems uninstalling apps from the home screen does leave some intent or activities in some cache somewhere.

Leave a Comment