Android Studio 安装失败,因为设备已有更新版本

ale*_*lex 7 android upgrade version apk android-studio

我们编写了一个新版本的 Android 应用程序来升级旧的应用程序,但希望在升级后第一次运行时从旧应用程序 SharedPreferences 中提取登录用户名,然后用新数据模型覆盖整个内容。新代码库的 build.gradle 指定了更新的 versionName 和 versionCode,但是当我们尝试从 Android Studio 运行到安装了旧应用程序的设备上时,我们会收到一个包含以下错误消息的对话框:

Installation failed since the device already has a newer version of this application.
In order to proceed, you have to uninstall the existing application.

WARNING. Uninstalling will removed the application data!

Do you want to uninstall the existing application?

[OK] [Cancel]
Run Code Online (Sandbox Code Playgroud)

显然,如果我们接受它会卸载旧应用程序以及所有用户数据,我们将无法实现我们的预期。

无法在互联网上找到有关此问题的任何信息

错误信息

旧APP build.gradle:

versionCode 1
versionName '1.4.1'
Run Code Online (Sandbox Code Playgroud)

新应用程序 build.gradle:

versionCode 2
versionName '2.0.0'
Run Code Online (Sandbox Code Playgroud)

Ana*_*oid 0

为了进行测试,您可以将版本代码更改为设备中当前安装的版本代码。