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
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 :)