Manually installing an updated APK fails with "signatures do not match the previously installed version"

Android

Android Problem Overview


I've built a silly app to share among a few friends. No need to put it up on the app-store.

I built the first apk (signed), uploaded it to a web-server and all worked well.

A small issue arose, I fixed it, re-built, signed with the same keystore and uploaded it again. It now seems that I am unable to install from the new apk. The debugger tells me:

signatures do not match the previously installed version

So I uninstalled the old version by opening the app drawer and dragging it onto the "uninstall" button. When opening "Settings -> Apps", I don't see it anywhere anymore. I don't see any traces of the app on my device.

Yet I still get the above error message.

Is it possible some information still lingers on the device somewhere? Is there any way I can verify that?

Android Solutions


Solution 1 - Android

Yes It is possible if somehow your old application is not removed 100% or its data is not removed.

Try:

adb uninstall "com.yourapp.yourapp"

If you don't know exactly what to put as replacement for "com.yourapp.yourapp", then you just open Android studio, Run your app while it is connected to a device and then look at Debug window.

It says:

 Waiting for device.
 Target device: samsung-sm_t531-xxxxxxxxx
 Uploading file
 local path: C:\Users\myapp\app\build\outputs\apk\myapp.apk
 remote path: /data/local/tmp/com.myapp.myapp
 Installing com.myapp.myapp
 DEVICE SHELL COMMAND: pm install -r "/data/local/tmp/com.myapp.myapp"
 pkg: /data/local/tmp/com.myapp.myapp
 Success

com.myapp.myapp in this case is the name of the package you must use to uninstall.

Solution 2 - Android

I had the same issue and the adb uninstall solution did not work for me.

What worked was

  • On your device go to to Settings->Apps
  • Select your app, and in the menu select "Uninstall for all users"

Even if I had previously uninstalled the app it was still in the list there.

Solution 3 - Android

To me, if the app is meant to be distributed, the adb solution is a no-go: you can't ask one's friend to have the android sdk installed on their machine !

The way to go here is to edit the AndroidManifest.xml and to increment the android:versionCodeattribute in the <manifest>tag (which is the root element).

This would update your installed application

Solution 4 - Android

If you are seeing this while conducting connected tests, make sure to include .test when uninstalling via adb because uninstalling via app -> settings does not get rid of the test package

adb uninstall your.broken.package.test

if you just uninstall via

adb uninstall your.broken.package

your test package will still be there. This was only something i noticed while using the gradle command line, haven't come across this problem within android studio

Solution 5 - Android

Uninstall the old app from your phone or emulator and try to run again.

Solution 6 - Android

I got that error while trying to install release while signing it's certificate.

fixed with the :app Gradle task uninstallRelease and then installRelease again

Solution 7 - Android

For Unity users who come to this question, the best answer is indeed the one above by @Ehsan

adb uninstall "com.yourapp.yourapp"

I had already installed a previous version on my Android device then selected Development Build in Unity > Build Settings which caused the APK to use a different signature. If you install through the Android GUI it doesn't actually remove everything so you have to use ADB.

Solution 8 - Android

If you are going in install the same app with a different signature, you may want to uninstall but keep the app's data.

adb -d shell pm uninstall -k <packageName>
adb -d install -r -t -d app.apk

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionexhumaView Question on Stackoverflow
Solution 1 - AndroidEhsanView Answer on Stackoverflow
Solution 2 - AndroidJulienView Answer on Stackoverflow
Solution 3 - AndroidGreg BergerView Answer on Stackoverflow
Solution 4 - AndroidJoe MaherView Answer on Stackoverflow
Solution 5 - Androidirfan AYDINView Answer on Stackoverflow
Solution 6 - AndroidEF5View Answer on Stackoverflow
Solution 7 - Androidow3nView Answer on Stackoverflow
Solution 8 - AndroidLanDenLabsView Answer on Stackoverflow