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

I am creating an Android application 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, 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 application version code is set to 3, both times I create it. Where does the idea that the update is "version 0" come from?

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 am sure it worked, but now it does not look like. If I replaced the @integer link with the hard-coded "3", it will work. Shouldn't @integer be supported?

+4
source share
1 answer

As far as I know, no , you cannot do this.

See this discussion on Google Groups and this stack overflow question for some ideas to achieve a similar result when building ant scripts.

If you look at the Android documentation , it specifically states that you can use the resource for versionName , but there is no such thing for versionCode :

android:versionCode

Internal version number. This number is only used to determine if one version is later than the other, with higher numbers indicating later versions. This is not the version number shown to users; this number is specified by the versionName attribute.

The value must be set as an integer, for example, "100". You can define it but you want it if each subsequent version has a higher number. For example, it could be an assembly number. Or you could translate the version number in the format "xy" to an integer by encoding "x" and "y" separately in the lower and upper 16 bits. Or you can simply increase the number every time a new version is released.

android:versionName

Version number shown to users. This attribute can be set as a raw string or as a reference to a string resource . The line has no other than for display to users. The versionCode attribute is the significant version number used internally.

+2
source

Source: https://habr.com/ru/post/1488785/


All Articles