Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: "update version 0 is older than installed version"

Tags:

android

I'm building an Android app in release mode. The first time I install it on a device, it works fine. But if I rebuild it from the same source, sign it with the same key, and reinstall, it fails. I get the following error in the logs:

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

The version code of the app is set to 3, both times I build it. Where is it getting the idea that the update is "version 0"?

UPDATE: I have this in my manifest file: android:versionCode="@integer/app_version_code". And I have <integer name="app_version_code">3</integer> defined in res/values/strings.xml.

I'm pretty sure this used to work, but now it doesn't seem to. If I replace the @integer reference with a hard-coded "3", it works. Shouldn't @integer be supported?

like image 305
JW. Avatar asked Nov 02 '22 19:11

JW.


1 Answers

As far as I know, no, you can't do that.

See this Google Groups discussion, and this Stack Overflow question for some ideas for achieving a similar outcome with ant build scripting.

If you look at the Android documentation, it specifically calls out that you can use a resource for the versionName, but says no such thing for the 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.

like image 138
Nate Avatar answered Nov 11 '22 11:11

Nate