Can’t deploy apk via Android Studio – stale dexed jars / INSTALL_FAILED_UID_CHANGED

Issue

Can’t re-deploy application apk that was already installed on a device via Android Studio. Application build would complete fine, but apk install stops with following warning:

Application Installation Failed

Installation failed since the device possibly has stale dexed jars that don’t match the current version (dexopt error).
In order to proceed, you have to uninstall the existing application.
WARNING: Uninstalling will remove the application data!
Do you want to uninstall the existing application?

After clicking OK deployment would still fail with “Unknown Failure” error:

Installing com.package.name
DEVICE SHELL COMMAND: pm install -r /data/local/tmp/com.package.name”
pkg: /data/local/tmp/com.package.name
Failure [INSTALL_FAILED_DEXOPT]
DEVICE SHELL COMMAND: pm uninstall com.package.name
Unknown failure

Subsequent install attempts would fail with “INSTALL_FAILED_UID_CHANGED” error:

Installing com.package.name
DEVICE SHELL COMMAND: pm install -r /data/local/tmp/com.package.name”
pkg: /data/local/tmp/com.package.name
Failure [INSTALL_FAILED_UID_CHANGED]

Out of interest, I also tried to re-installed the application via Google Play (since it was already published). This failed with “Unknown error -24“:

Unknown error during application installation -24

Unknown error code during application
installation: “-24”

Resolution

Most suggestions I managed to find online were to do with cleaning /data/data/com.package.name directory on the device. This can be easily done in the emulator or on a rooted device, but not so simple on an unrooted physical device. So without much thinking I reset the phone to the factory defaults which to much of my surprise didn’t resolve the issue…

The fix was actually much simpler. All I had to do was to clean the gradle build. In Android Studio this can be done by clicking on Built > Clean Project.

Android Studio > Build > Clean Project

Windows 7 Pro 64bit
Android Studio 1.0.2

Samsung S4 Mini


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *