gpt4 book ai didi

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

转载 作者:太空狗 更新时间:2023-10-29 14:47:23 27 4
gpt4 key购买 nike

我们已经编写了一个新版本的 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]

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

在互联网上找不到关于这个问题的任何信息

error message

旧APP build.gradle:

versionCode 1
versionName '1.4.1'

新APP build.gradle:

versionCode 2
versionName '2.0.0'

最佳答案

我认为发生此错误是因为您的旧应用程序的 versionCode 高于新应用程序。

因此,如果与旧应用相比,您必须将新应用的 versionCode 更新为更高(或至少相等)的值。

在新应用中:

构建等级

android {
...
defaultConfig {
...
versionCode 2
versionName "1.1"
}
...
}

如果您的旧版本是在 Eclipse 中构建的,versionCode 可能是在 AndroidManifest.xml 中定义的

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="string"
android:versionCode="integer"
android:versionName="string"
. . .
</manifest>

关于Android Studio 安装失败,因为设备已经有更新的版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38395889/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com