安卓: "update version 0 is older than installed version"

标签 android

我正在以 Release模式构建 Android 应用。我第一次在设备上安装它时,它运行良好。但是,如果我从相同的来源重建它,使用相同的 key 对其进行签名,然后重新安装,它就会失败。我在日志中收到以下错误:

W/InstallAppProgress(30456): Replacing package:com.mycompany.myapp
W/ActivityManager(26370): No content provider found for permission revoke: file:///storage/emulated/0/Download/MyApp-17.apk
W/PackageManager(26370): Can't install update of com.mycompany.myapp update version 0 is older than installed version 3

应用程序的版本代码设置为 3,我两次构建它。它从哪里得到更新是“版本 0”的想法?

更新:我的 list 文件中有这个:android:versionCode="@integer/app_version_code"。我在 <integer name="app_version_code">3</integer> 中定义了 res/values/strings.xml

我很确定这曾经有效,但现在似乎无效了。如果我用硬编码的“3”替换@integer 引用,它就可以工作。不应该@integer be supported 吗?

最佳答案

据我所知,,你不能那样做。

See this Google Groups discussion , 和 this Stack Overflow question了解使用 ant 构建脚本实现类似结果的一些想法。

如果您查看 Android documentation ,它明确指出您可以versionName使用资源,但没有为versionCode说这样的话:

android:versionCode

An internal version number. This number is used only to determine whether one version is more recent than another, with higher numbers indicating more recent versions. This is not the version number shown to users; that number is set by the versionName attribute.

The value must be set as an integer, such as "100". You can define it however you want, as long as each successive version has a higher number. For example, it could be a build number. Or you could translate a version number in "x.y" format to an integer by encoding the "x" and "y" separately in the lower and upper 16 bits. Or you could simply increase the number by one each time a new version is released.

android:versionName

The version number shown to users. This attribute can be set as a raw string or as a reference to a string resource. The string has no other purpose than to be displayed to users. The versionCode attribute holds the significant version number used internally.

关于安卓: "update version 0 is older than installed version",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17374672/

相关文章:

android - ListView 无限构建项目

android - 由于网络政策存在问题,我的应用被 Google Play 拒绝了?

android - 将重要数据存储在内部存储器中

android - 以编程方式检查 ListView 中的项目

android - toast 和持续时间

android - 写入SD卡

android像whatsApp一样在listview上获取日期

android - 我是否必须通过我的 Activity 清理所有对话框 'show'

android - 如何从 Android 将 Http 发布到 Django 服务器?

android - 保持 wifi radio 打开的不同可能性?