42

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.

Hamed
  • 5,867
  • 4
  • 32
  • 56
Anuran Barman
  • 1,556
  • 2
  • 16
  • 31

25 Answers25

43

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.

ghirlekar
  • 1,071
  • 1
  • 9
  • 10
  • 8
    Uninstalling using `adb uninstall com.package.name` works. The device was used for debugging, but when it comes to installing CI/CD builds, it fails. –  Jun 24 '19 at 04:34
  • If you have multiple bundle ids (`com.package.name`, `com.package.name.dev`, `com.package.name.staging`) then make sure you uninstall all of them using the adb command. – Pedro Massango Jan 27 '22 at 14:53
13

For me it happens when there are multiple users in the device. When you run the flutter app, it installs the app in all user profiles. So when you just uninstall the app, it only uninstalls the app in the current profile. But the app remains installed in the other profiles. That causes problem when you rerun the app.

To resolve this

  • Go to App Info
  • Click on the top right menu
  • Click on Uninstall for all users

This instructions are only for devices running Stock Android 10.

  • this is working with my problems, and yes there are 2 Profiles on a single phone and the app is installed double. – Obink Jul 25 '21 at 07:22
10

I got same problem yesterday and I have tried all the solution.

Finally I got the solution as I have added --no-shrink in command of building apk.

flutter build apk --no-shrink

Hope it will work.

Thank you.

Pratik Butani
  • 60,504
  • 58
  • 273
  • 437
4

Make sure you don't have a work profile on your device. If you do, you need to uninstall all the same apps under your personal profile and work profile.

Jeffrey Liu
  • 1,063
  • 1
  • 9
  • 18
3

Remove all other user profiles from your android phone. Only keep the admin profile. This worked for me!

I also tried re creating the emulator as I sometimes use emulator as well. In case , you are using an emulator create a new one and delete the old one.

heypran
  • 126
  • 1
  • 11
2

It because your previous installed app has crashed at app installing state so if you are trying to build another app using that previous name the app won't install on your device. Try with different name the it'll work.

2

U have to uninstall the app from different users(guest user, etc) of your phone too!!

Rishi Chhabra
  • 101
  • 1
  • 3
2

I too faced a similar issue, Your device may have multiple user profiles, so go through them and uninstall from them as well, then this problem will be solved!

Bhuvan Ade
  • 31
  • 1
1

I had the same issue, and I changed in 5 location.

  1. src/profile/AndroidManifest.xml
  2. src/debug/AndroidManifest.xml
  3. src/main/AdroidManifest.xml
  4. build.gradle.
    defaultConfig {
    applicationId
  5. MainActivity.java on "package"

After modifying the above files. I could run the app without any issues.

I found the issue was in src/main/AdroidManifest.xml.

Rishabh Agarwal
  • 1,988
  • 1
  • 16
  • 33
Jayant Dhingra
  • 526
  • 6
  • 11
1

For me, on Xiaomi phone, which has a second space, I had to remove the app from the second space also after I've removed it from the first space manually.

EmadFathy
  • 158
  • 1
  • 9
1

You can also check if you have enough storage in your device, both physical and the AVD.

0

I tried to uninstall the application with adb uninstall but it doesn't work for me. My solution is to use adb install -r "myapp-release.apk" to re-install the application

code4j
  • 4,208
  • 5
  • 34
  • 51
0

Same issues happen on new flutter project after with AndroidX release build with signed configuration after upgrade Android SDK 29.

-- Config -- Android SDK 29, Gradle 5.4.1 dependencies .. com.android.tools.build:gradle:3.4.1 Flutter stable v1.5.4-hotfix-2

-- work around -- update Android\App\build.gradle as below.

1) Disable minifyEnable and proguarde. add 3 more dependencies (which not include in new flutter project).

2)

implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.android.material:material:1.0.0'
Ko Lynn
  • 134
  • 4
  • 8
0

The problem is flutter apps will be installed in all users in your real phone

in my case: younes is the main user and yns is a second user Show image

-> this is my main user (younes) I unstalled all flutter apps so this should delete all the flutter apps from my phone but this not the case

Show image

-> this is my second user (yns) still have 4 installed flutter apps even I unstalled the apps from the main user

Show image

the solution is to make sure that you unstalled your flutter app from all users, not just the main user

0

I was not able to resolve the issue by uninstalling the package or cleaning flutter build. Issue was due to remaining package files after manual uninstall from home screen. You can resolve the issue by trying to remove the application from all the users including guest.

If you do not require the guest user you can remove it by Switching to the Guest user -> swipe down quick setting -> Click of Guest user icon -> Remove Guest.

0

Please execute flutter clean and try again.

This worked for me!

MJ Montes
  • 3,234
  • 1
  • 19
  • 21
Shady Mohamed Sherif
  • 15,003
  • 4
  • 45
  • 54
0

I am not able to install and debug APK in physical device after Flutter Upgrade. Also device keep on restarting. After updating Flutter version, I resolved the issue by, updating Visual Studio Code.

abbas-ak
  • 642
  • 3
  • 13
0

For Android mobile, Uninstall the installed app in the Work Profile. Once you link it with your work email, Android forces to create Work Profile and the flutter app also installed in your Work profile too.

It happens when you delete the app on your Personal profile, it still remains in your Work profile, and the app no longer installed to your Personal profile and stops process.

Cheers.

stevec
  • 134
  • 1
  • 4
0

So your app keeps installing indefinitely without stoping or succeeding? There could be several causes to this.

  1. You've minimised the same app you want to reinstall on your android device instead of properly closing it properly.

FIX: close the app properly and try the reinstallation process again.

  1. You have multiple user profiles on your android device and despite already uninstalling the app from your current user profile, somehow, it's still installed on another user profile present in the phone.

FIX: login to the various user profiles, look for the app there and uninstall it if it exists. try the reinstallation process again and everything should work perfectly as expected.

0

I had a same problem, buildTypes in build.gradle is reason for this problem.

1)go to android --> app --> build.gradle

2)under android { buildTypes { release entry uncomment following code:

  signingConfig signingConfigs.debug

3)the code must be like following:

 buildTypes {
    release {
        // TODO: Add your own signing config for the release build.
        // Signing with the debug keys for now, so `flutter run -- 
           release` works.
        signingConfig signingConfigs.debug
    }
 }
Hekmat
  • 153
  • 5
0

I don't know why it happens suddenly due to some changes in pubspec or anyting related to dart, only thing works for me

Either

1.Run flutter clean

2.flutter run

or

Simply open android module and sync gradle then run. This method works every time. It automatically fixes previous issue of unable to run from flutter.

pintu236
  • 148
  • 2
  • 11
0

Flutter App is not able to reinstall in Samsung device.

this happens due to cache data. so you can do this.

android:allowBackup="false" (add this flag in appNAme/android/app/src/main/AndroidManifest.xml -> inside Application section)

  • uninstall old apk
  • install new apk ( or made new apk by adding the above flag = android:allowBackup="false")
  • after install new apk just open it.
  • uninstall new apk also. ( this time new flag clear all old data)
  • and then install same apk.
amit.flutter
  • 883
  • 9
  • 27
0

Incase you struggle finding adb. Run this on terminal

brew install --cask android-platform-tools

once adb installed then you can run below code to check devices

adb devices

and finally can use this to uninstall the app

adb uninstall ${packageName}
Rohan majhi
  • 121
  • 1
  • 4
0

I was trying to debug a Flutter app on my Xiaomi phone using VSCode, but even after removing the app from the phone, I couldn't load the APK in debug mode. The issue turned out to be a 'guest' user on my phone, even though the multiple users feature was off.

I resolved this by:

  1. Enabling the "multiple users" feature in the system settings.
  2. Identifying and deleting the 'guest' user.

After these steps, I was able to load the APK in debug mode. Thanks to the previous posters for finding the solution.

Sornen
  • 1
  • 2
-2

First of all i want ti thank everyone who has contributed to this question, especially for the people who faced issues with many user profiles, well for my case it wasnt a typical user profile issue but i did have a second space in my phone which appears to act as a second user profile, well everything is now working fine after i deleted the second space because i had forgotten the pin, but for your case if you do know your pin, you can go in and try to uninstall the app there. thanks, hope this also helpes someone.

Romanric Akam
  • 663
  • 1
  • 5
  • 13