手动安装更新的 APK 失败,“签名与以前安装的版本不匹配”

我做了一个愚蠢的应用程序分享给几个朋友,没有必要把它放在应用程序商店。

我建立了第一个 apk(签名) ,上传到一个网络服务器和所有工作都很好。

出现了一个小问题,我修复了它,重新构建,用同一个密钥存储库签名,然后再次上传。现在看来,我无法从新的 apk安装。调试器告诉我:

signatures do not match the previously installed version

因此,我卸载旧版本打开应用程序抽屉,并拖动到“卸载”按钮。当打开“设置-> 应用程序”,我看不到它在任何地方了。我的设备上没有这个应用的痕迹。

但是我仍然得到上面的错误消息。

有没有可能 一些信息仍然滞留在设备的某个地方? 有没有什么办法可以证实这一点?

95069 次浏览

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.

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

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.

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

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

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

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.

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

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.