Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
924 views
in Technique[技术] by (71.8m points)

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

I am working with flutter currently and everything was fine suddenly when I uninstalled the app from the device and rerun flutter run from the terminal it's suddenly not able to install the apk into a real device. It's not even giving any error just getting stopped at the installation process.

What led to this problem

I was working with sqflite and everything was fine. So I had to change the schema and added another table which was failing. Searching on SO answerer suggested to uninstall the app then reinstall it (was accepted answer). So I did that but after every time when I am running flutter run it is not installing the APK.

I am running Mac Os High Sierra 10.13.6 and running flutter doctor is giving everything right as I said it was working fine but not reinstalling after uninstalling.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...