How to fix INSTALL_FAILED_INVALID_APK error in Android Studio?
Asked Answered
F

10

13

I have recently updated my Android Studio to 3.6.1, thereby also updating gradle plugin to 3.6.1 and the gradle wrapper to 5.6.4

When running the debug build, I keep getting this error

Install failed: The application could not be installed: 
INSTALL_FAILED_INVALID_APK 
The APKs are invalid. 
  • I have checked my package and applicationId and it is the same
  • I tried using android:extractNativeLibs="true" on the manifest <application> tag and it is still does not work
  • Kept on cleaning and rebuilding still doesn't work
  • Invalidated caches, deleted .gradle, idea, and build files and it still does not work
  • I have also used this on gradle.properties file org.gradle.caching=false but still does not work I checked the idea.log file and here is what it is saying:
2020-03-22 00:49:04,191 [4654427]   INFO - ild.invoker.GradleBuildInvoker - Gradle build finished in 1 m 37 s 411 ms 
2020-03-22 00:49:04,213 [4654449]   INFO - ools.idea.run.tasks.DeployTask - Installing application: PACKAGE_NAME 
2020-03-22 00:49:04,451 [4654687]   INFO - a.run.tasks.AbstractDeployTask - 20675813ms TRC_BEG [12861][12861] : installer 
2020-03-22 00:49:04,451 [4654687]   INFO - a.run.tasks.AbstractDeployTask - 20675814ms TRC_BEG [12861][12861] : Command Dump 
2020-03-22 00:49:04,451 [4654687]   INFO - a.run.tasks.AbstractDeployTask - 20675814ms TRC_BEG [12861][12861] : get process ids 
2020-03-22 00:49:04,451 [4654687]   INFO - a.run.tasks.AbstractDeployTask - 20675872ms LOG_ERR [12861][12861] : Could not get package user id: /system/bin/run-as: unknown package: PACKAGE_NAME 

2020-03-22 00:49:04,451 [4654687]   INFO - a.run.tasks.AbstractDeployTask - 20675874ms TRC_END [12861][12861] :  
2020-03-22 00:49:04,451 [4654687]   INFO - a.run.tasks.AbstractDeployTask - 20675874ms TRC_BEG [12861][12861] : retrieve_apk_path 
2020-03-22 00:49:04,452 [4654688]   INFO - a.run.tasks.AbstractDeployTask - 20675874ms TRC_BEG [12861][12861] : apk_path_via_cmd_package_dump 
2020-03-22 00:49:04,452 [4654688]   INFO - a.run.tasks.AbstractDeployTask - 20675923ms TRC_END [12861][12861] :  
2020-03-22 00:49:04,452 [4654688]   INFO - a.run.tasks.AbstractDeployTask - 20675923ms TRC_END [12861][12861] :  
2020-03-22 00:49:04,452 [4654688]   INFO - a.run.tasks.AbstractDeployTask - 20675923ms LOG_ERR [12861][12861] : Could not find apks for package: PACKAGE_NAME 
2020-03-22 00:49:04,452 [4654688]   INFO - a.run.tasks.AbstractDeployTask - 20675923ms TRC_END [12861][12861] :  
2020-03-22 00:49:04,452 [4654688]   INFO - a.run.tasks.AbstractDeployTask - 20675923ms TRC_END [12861][12861] :  
2020-03-22 00:49:04,452 [4654688]   INFO - a.run.tasks.AbstractDeployTask - DUMP_UNKNOWN_PACKAGE 
2020-03-22 00:49:04,967 [4655203]   INFO -            #com.android.ddmlib - Created install session 969164047 with options -r -t -S 14667707 
2020-03-22 00:49:04,967 [4655203]   INFO -            #com.android.ddmlib - Uploading APK C:\Projects\PROJECT_FOLDER\source\PROJECT_NAME\app\build\outputs\apk\debug\app-debug.apk to session 969164047 
2020-03-22 00:49:08,055 [4658291]   INFO - WindowsPerformanceHintsChecker - Windows Defender status: NONE_EXCLUDED; projectDirExcluded? false 
2020-03-22 00:49:17,686 [4667922]   WARN -            #com.android.ddmlib - Failed to commit install session 969164047 with command cmd package install-commit 969164047. Error: INSTALL_FAILED_INVALID_APK: Package couldn't be installed in /data/app/PACKAGE_NAME -d9UfJVvKMP9-OA81TwCVvQ==: Package /data/app/PACKAGE_NAME -d9UfJVvKMP9-OA81TwCVvQ==/base.apk code is missing 
2020-03-22 00:49:17,687 [4667923]   WARN - a.run.tasks.AbstractDeployTask - Install failed: The application could not be installed: INSTALL_FAILED_INVALID_APK The APKs are invalid. 
2020-03-22 00:49:17,689 [4667925]   INFO - run.AndroidLogcatOutputCapture - stopAll() 
2020-03-22 00:49:21,408 [4671644]   INFO - rationStore.ComponentStoreImpl - Saving appEditorColorsManagerImpl took 12 ms 

*Take note I replaced my package name with PACKAGE_NAME and project names

I have run out of options. Worst case is I will downgrade gradle and gradle wraper and even Android Studio, which I deliberately hate as it is a step backwards

Fashoda answered 21/3, 2020 at 17:0 Comment(9)
same issue for release build?Virgievirgil
I haven't checked release build yetFashoda
I tried generating debug APK and it didn't install. Only showed "App install failed"Fashoda
I'm going to try with a release APK but I'm still thinking it would still have the same resultFashoda
FIND same problem with you,but i can run the app on real phone,not on virtual machine,i think may the third party .so file not support run on the virtual machine.Crackleware
Same issue...doesn't work on physical device (Pixel 4) or emulator (Pixel 3a). Staying with older version of gradle for now, but would like to know a solution.Artilleryman
show your manifest file & gradle file. It may be small issue.Virtual
Just to be clear, for me, the app installs fine if I stay with Gradle 5.4.1 and android build tools 3.5.1. But if I only change Gradle to 5.6.4 and android build tools to 3.6.1, then the app will not install (actually it builds incorrectly according to the error).Artilleryman
I am in the same situation as @Innova. Android Studio has an update today. I am trying if they have fixed the issue in this versionFashoda
F
8

I tried updating the Android Studio but it still get the INSTALL_FAILED_INVALID_APK error. Then I updated the firebase dependencies and still to no avail

Interestingly though, it worked smoothly on another project that I have. Which led me to check which dependencies they differ in and realized that the only major dependency is the AppDynamics gradle plugin

I remove the AppDynamics instrumentation and it worked! I am assuming that even before, the AppDynamics instrumentation in gradle was the cause that prevented the app from running properly. I have confirmed it is an issue with the AppDynamics plugin. See link for reference: https://community.appdynamics.com/t5/End-User-Monitoring-EUM/AppDynamic-EUM-setup-for-Android-Cordova-project/td-p/38864

For the meantime, I will be downgrading until AppDynamics provides a fix

Fashoda answered 6/4, 2020 at 6:0 Comment(7)
Thanks, we are also using App Dynamics.Artilleryman
What exactly did you downgrade? AppDynamics, AS or the AppDynamics Gradle plugin? What version did you downgrade to? I'm experiencing the same problemAbdel
Found it: Downgrading gradle build tools to 3.5.0 is a workaround.Abdel
Thank you, it was AD problem for us as wellEldridgeeldritch
Problem not present using appdynamics 20.5.2Genocide
OMG. Thank you.. If I haven't found this post it'd be many more hours of wtf'sAggi
Luckily I saw this post:)Karaganda
O
19

One other solution would be just remove the ../android/app/build/outputs/apk/debug/app-debug.apk file and then run "npm run android" / "yarn android"

Oakum answered 2/8, 2020 at 23:28 Comment(1)
not sure why this got a -1, it worked for me, got this error after I updated my gradle versionPetrillo
F
8

I tried updating the Android Studio but it still get the INSTALL_FAILED_INVALID_APK error. Then I updated the firebase dependencies and still to no avail

Interestingly though, it worked smoothly on another project that I have. Which led me to check which dependencies they differ in and realized that the only major dependency is the AppDynamics gradle plugin

I remove the AppDynamics instrumentation and it worked! I am assuming that even before, the AppDynamics instrumentation in gradle was the cause that prevented the app from running properly. I have confirmed it is an issue with the AppDynamics plugin. See link for reference: https://community.appdynamics.com/t5/End-User-Monitoring-EUM/AppDynamic-EUM-setup-for-Android-Cordova-project/td-p/38864

For the meantime, I will be downgrading until AppDynamics provides a fix

Fashoda answered 6/4, 2020 at 6:0 Comment(7)
Thanks, we are also using App Dynamics.Artilleryman
What exactly did you downgrade? AppDynamics, AS or the AppDynamics Gradle plugin? What version did you downgrade to? I'm experiencing the same problemAbdel
Found it: Downgrading gradle build tools to 3.5.0 is a workaround.Abdel
Thank you, it was AD problem for us as wellEldridgeeldritch
Problem not present using appdynamics 20.5.2Genocide
OMG. Thank you.. If I haven't found this post it'd be many more hours of wtf'sAggi
Luckily I saw this post:)Karaganda
J
3

Deleting existing app on the phone with same bundle ID worked for me.

Jonellejones answered 20/11, 2020 at 1:20 Comment(0)
I
2

Sometimes it is because of the emulator/device you are installing your apk on. If you have previously installed apk on a device and then uninstalled, then it might still exist on your device. So, in the emulator, go to settings -> Apps, then check for the application in the list. If exist, click on that particular application and then click on 'Uninstall for all users'(Typically from three dots in right corner).

Hope it helps :)

Indocile answered 21/3, 2020 at 17:9 Comment(1)
I can't find it anymore in my device Settings and Apps listFashoda
B
1

I faced the same issue. Try to uninstall the app via terminal adb uninstall com.packagename command and then reinstall the app. Basically, sometimes the app is isntalled for other users in device and uninstalling from device just uninstalls it from current user, that's why it gives this error. Give it a try, I hope it will helps.

Butanone answered 31/3, 2020 at 8:28 Comment(0)
K
1

What works for me is to do the following:

  1. Uninstall the dev version (or store version of the app). If you have an app with the same bundle id it will refuse to install a different variation of the sample app. adb uninstall <BUNDLE_ID>
  2. refresh the android build cd ./android && ./gradlew clean && cd ../
  3. Run react-native run-android --variant=release
Kobe answered 2/4, 2021 at 18:7 Comment(0)
P
0

I remember having the same issue and solving it with build>clean project. but as you say that this doesnt work here is a link talking about subtle changes in your apps package name in the Manifest and its pretty recent. Just thought it might be woth a look as it does not appear in the list of things you have already checked. plus the logs you published talk about the package name being unknown so that seems suspicious.

I hope it helps

Panorama answered 31/3, 2020 at 7:17 Comment(1)
I have already checked it and it is the same, I can't change my package name as wellFashoda
E
0

When you are set up the emulator (AVD) you are choosing the External & Internal storage sizes.

enter image description here

AND I think you exceeded that storage size.

Solutions (They are all under freeing some storage "category"):-

  • Uninstall unnecessary apps.
  • Wipe emulator data from AVD manager.
  • Extend the storage size by editing the specific emulator.
Etz answered 31/3, 2020 at 7:53 Comment(1)
I am not using emulator and I am using Note 0 actual device with 128gb storageFashoda
S
0
application>- android:extractNativeLibs="true" 

work for me


minSdkVersion 23

ndk {
   abiFilters "armeabi-v7a"
}

minSdkVersion is less than 23, work for me too

Stereotropism answered 29/4, 2020 at 9:30 Comment(1)
work for me too, thank you!Broome
A
0

The problem started happening for me in Android Studio 4.0. I get "INSTALL_FAILED_INVALID_APK" when trying to launch an app on Emulator right after opening Android Studio.

Found a workaround - if I launch the app on real device first, then launching on emulator is not a problem. Works 100%.

Android Studio is still buggy as hell, unfortunately...

Aube answered 29/6, 2020 at 9:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.