Android Studio 因为签名拒绝安装应用

Android Studio refuses to install app because of signature

我有 Android Studio 4.1.3,今天我将 phone 更新为 Android 11.

我打开我的 Android Studio,一个应用程序,当我尝试将应用程序安装到 phone with studio 时,它告诉我:

The device already has an application with the same package but a different signature.
In order to proceed, you will have to uninstall the existing application

WARNING: Uninstalling will remove the application data!

Do you want to uninstall the existing application?

我的应用强烈使用外部存储,我的用户在其中拥有数十 GB 的数据。他们不能卸载他们的应用程序!

为什么会发生这种情况,工作室在谈论什么签名,我该如何解决这个问题?

这可能是我的#HOME/.android 文件夹有问题吗?我搞砸了...

如果您从 Playstore 安装了应用程序,它基本上已经使用他们的密钥进行了签名。如果您已经从 Playstore 安装了相同的应用程序,并且您尝试安装具有相同包名和发布版本的完全相同的应用程序,您将得到这个..

因此,如果您从 Android studio 安装或简单地从 Android Studio 本身卸载并重新安装,那么解决方案就是 select debug version

同时检查您是否定位 API level 30 in build gradel

查看文档 Set up the Android 11 SDK and Compatibility framework tools

我用旧备份恢复了我的 $HOME/.android 文件夹,一切正常。可能我搞砸了或删除了我的原始签名文件。