Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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.

like image 200
Anuran Barman Avatar asked Aug 12 '18 13:08

Anuran Barman


People also ask

How do you solve if flutter run stuck at installing APK?

To do this, go into your device or emulator: Settings > Developer options , Change the buffer size to a higher number. Then run flutter run -v again.

How do I run the Flutter app on Android real device?

Using a USB cable, plug your phone into your computer. If prompted on your device, authorize your computer to access your device. In the terminal, run the flutter devices command to verify that Flutter recognizes your connected Android device.

Why does it say app not installed APK?

Insufficient Storage- If your Android device is too full, it causes the package installer to malfunction, leading to the 'App not Installed' pop-up. Even a corrupted Internal Storage Card or an SD card which is not mounted properly may lead to clogged storage and thus give you the App not installed error message.


1 Answers

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.

like image 108
ghirlekar Avatar answered Sep 18 '22 17:09

ghirlekar