Search code examples
androidinstallationapkkeystoresignature

Cannot update debug APK on device


I face a problem when trying to install debug type .apk file over another one on my device. I have an app with versionCode=n already installed. When I try to install the same app with versionCode=n+1 i get an error.

Here is the message after i call the command adb install xxx.apk

failed to install xxx.apk: Failure [INSTALL_FAILED_UPDATE_INCOMPATIBLE: Package xxx signatures do not match the previously installed version; ignoring!]

All my .apk files are signed with Android debug keystore. It is confirmed by command jarsigner -verify -verbose -certs xxx.apk that gives me next message:

  • Signed by "C=US, O=Android, CN=Android Debug" Digest algorithm: SHA-256 Signature algorithm: SHA256withRSA, 2048-bit key

jar verified.

These .apk files are built via TeamCity CI that just calls assembleDebug command.

It is very strange because I can update release APK files built by CI easily. This problem occurs only in case of debug builds.

Do you have any idea about this? Thanks in advance


Solution

  • Each debug build of your android application will be signed with the debug keystore.

    This is a problem because in continous integration environments, like travis-ci or docker, the debug keystore is regenerated on each creation of the environment.

    This means if someone has a debug version of your application, they won't be able to upgrade to a more recent version, because the keystores will be different.

    Credits to: https://newfivefour.com/android-debug-build-constant-signed-keystore.html

    Also to compare if two apks are signed with the same key: check: How do I find out which keystore was used to sign an app?