解决 adb install 时 INSTALL_FAILED_UPDATE_INCOMPATIBLE 签名不匹配错误

解决 adb install 时 INSTALL_FAILED_UPDATE_INCOMPATIBLE 签名不匹配错误


在使用 React Native 构建 Android Release APK 后,通过 adb 安装时,可能会遇到如下错误:

adb: failed to install app-release.apk: 
Failure [INSTALL_FAILED_UPDATE_INCOMPATIBLE: Existing package signatures do not match newer version]

这个问题并不是编译失败,而是 Android 安装机制阻止了不同签名的应用覆盖安装


为什么会出现这个错误?

Android 系统要求:同一个包名的 App,在更新时必须使用相同的签名证书。

如果你之前安装的是:

  • Debug 版本(默认签名)
  • 或者使用了不同的 Release Keystore

而现在你安装的是新的 Release APK(使用了不同签名),系统就会拒绝更新,从而出现此错误。


解决方法

方法 1:卸载旧应用(最简单)

adb uninstall com.westminstershortercatechismqa
adb install app-release.apk

卸载后再安装即可正常运行。

方法 2:使用统一的 Release Keystore

如果你希望以后可以直接覆盖安装(升级 App),需要保证每次构建 Release 都使用同一个 keystore。

android/app/build.gradle 中配置:

android {
  signingConfigs {
    release {
      storeFile file("release.keystore")
      storePassword "your_password"
      keyAlias "your_alias"
      keyPassword "your_password"
    }
  }
  buildTypes {
    release {
      signingConfig signingConfigs.release
    }
  }
}

总结

情况建议处理方式
只想安装一次先卸载旧应用
希望以后正常升级统一使用同一个 keystore
只是本地调试安装 Debug APK 即可

完成以上步骤后,你就可以成功安装和升级你的 React Native Android 应用了。

希望这篇文章能帮到你!

❤️ Support This Blog


If this post helped you, you can support my writing with a small donation. Thank you for reading.


Comments

Popular posts from this blog

fixed: embedded-redis: Unable to run on macOS Sonoma

Copying MDC Context Map in Web Clients: A Comprehensive Guide

Reset user password for your own Ghost blog