88

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?

exhuma
  • 20,071
  • 12
  • 90
  • 123

9 Answers9

185

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.

Paolo
  • 20,112
  • 21
  • 72
  • 113
Dr. Ehsan Ali
  • 4,735
  • 4
  • 23
  • 37
  • 1
    This was indeed the issue. I did deploy it once on the phone directly from Android Studio. It seems this version was not properly removed. A final question: is there a way to do this from Android Studio? Or run adb directly from there? – exhuma Jul 19 '15 at 07:08
  • Yes, just try to learn how to execute shell commands from your android app. This thread is a good starting point : http://stackoverflow.com/questions/20932102/execute-shell-command-from-android – Dr. Ehsan Ali Jul 19 '15 at 07:43
  • nonono. Not running commands from my app ;) I was wondering if I can run `adb` directly from "Android Studio". – exhuma Jul 19 '15 at 08:05
  • 2
    This is good when you are developer.. But for any end user, if the same problem occurs then you need to follow: The issue was that in newer versions of Android, uninstalling in some manner only uninstalls for that specific user. The answer is to go to settings > apps > Go inside particular app and then to select "uninstall for all users" from the "..." menu item in the upper right. – AnkitRox Mar 03 '16 at 08:32
  • Happened to me because I changed the package name. uninstalling did the trick – Guy Sopher Sep 17 '16 at 11:39
  • @Ehsan i tried and it worked , and now i am supposed to send the APK to my client . after installing this APK will there be any loss in previous stored data? or any kind of data loss . ? – Rashid Kalhoro Jan 23 '19 at 05:29
  • @RashidKalhoro: Your app data is safe upon upgrade. – Dr. Ehsan Ali Jan 24 '19 at 06:05
24

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.

Julien
  • 1,028
  • 9
  • 18
  • Yes, this can happen as well if you have multiple user accounts on your device and the app is installed on more than one. If you uninstall it for one user, it only gets "unlinked" from that account. But it remains on disk. It will only be fully removed when each user has uninstalled it. – exhuma Dec 18 '16 at 11:28
  • 1
    "Uninstall for all users" worked perfectly. Removed all other users ))) – Inoy Jan 13 '17 at 01:03
  • i only see "uninstall" not "uninstall for all users" using an emulator pixel 3 29 – Pix81 Feb 21 '20 at 19:49
9

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

Greg Berger
  • 714
  • 7
  • 10
  • 1
    The issue was actually caused by me installing the app on a device via android studio during development. Rebuilding a new APK and distributing it was perfectly fine for everyone but me. So the adb solution was OK. – exhuma Jun 11 '16 at 15:38
4

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

Joe Maher
  • 5,354
  • 5
  • 28
  • 44
3

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

  • This is not an answer. SO stated that he has already tried this and the problem was still there. – BenRoob Jul 26 '17 at 15:54
1

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

EF5
  • 21
  • 1
1

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
LanDenLabs
  • 1,566
  • 16
  • 10
  • As far as I know the kept data are still bound to the old signature, so you will again get the error "signatures do not match the previously installed version" if you just try to install the new apk with a different signature. But the presented `adb install` command specified `-r` the old data are deleted automatically. But then keeping the data in the first command doesn't make much sense... – Robert Apr 14 '22 at 13:07
0

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.

ow3n
  • 5,974
  • 4
  • 53
  • 51
0

I had face same problem With POCO Mobile and Moto G30 Mobile while developing application in flutter

My Solution is:

I have open android project which automatically create in your project, in android studio and run project in connected device. It will automatically ask to uninstall old app with same package name and different signature. After click ok button it will install app.