[ 
https://issues.apache.org/jira/browse/CB-11742?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15471806#comment-15471806
 ] 

Joe Bowser edited comment on CB-11742 at 9/7/16 9:09 PM:
---------------------------------------------------------

Use the android-versionCode preference to set your version code on the build.  
You're one of two people who think this is a problem, and didn't ask me and 
other developers to rip this out over and over again.  I can direct you to the 
still open issue where people are demanding that this code be completely 
deleted because they're hitting MAX_INT and having other APK problems.  This is 
a scenario where the community has loudly dictated what needs to be done.

The history of this issue can be found here: CB-8976

https://cordova.apache.org/docs/en/latest/config_ref/


was (Author: bowserj):
Use the android-versionCode preference to set your version code on the build.  
You're one of two people who think this is a problem, and didn't ask me and 
other developers to rip this out over and over again.  I can direct you to the 
still open issue where people are demanding that this code be completely 
deleted because they're hitting MAX_INT and having other APK problems. 

The history of this issue can be found here: CB-8976

https://cordova.apache.org/docs/en/latest/config_ref/

> After upgrading to version 6.3.1, apps won't install in Android because they 
> are detected as DOWNGRADE
> ------------------------------------------------------------------------------------------------------
>
>                 Key: CB-11742
>                 URL: https://issues.apache.org/jira/browse/CB-11742
>             Project: Apache Cordova
>          Issue Type: Bug
>      Security Level: Public(Anyone can view this level - this is the 
> default.) 
>          Components: Android
>    Affects Versions: 6.3.1
>         Environment: Developing on Windows 8.1 with node v5.1.0, cordova 
> 6.3.1 for android
>            Reporter: David Martinez Borque
>              Labels: android, triaged
>
> I have updated to cordova 6.3.1
> Then I compile all my apps, generating new release apks (v.1.17).
> Then I try to install the new apk into an android device where I already have 
> an older version of the app (v 1.16)
> When upgrading the app (adb install -r android-release.apk) I always get this 
> error:
> [INSTALL_FAILED_VERSION_DOWNGRADE]
> Most curiously, when I install the new apk  (with adb install -r -d) the 
> Android system detects that the version of the app is 1.17!!
> ----------------------------> further on...<---------------------------
> I found a workaround for this problem. I modified the build.gradle file from:
> {code}
>     /*
>     ELSE NOTHING! DON'T MESS WITH THE VERSION CODE IF YOU DON'T HAVE TO!
>     else if (!cdvVersionCode) {
>       def minSdkVersion = cdvMinSdkVersion ?: 
> privateHelpers.extractIntFromManifest("minSdkVersion")
>       // Vary versionCode by the two most common API levels:
>       // 14 is ICS, which is the lowest API level for many apps.
>       // 20 is Lollipop, which is the lowest API level for the updatable 
> system webview.
>       if (minSdkVersion >= 20) {
>         defaultConfig.versionCode += 9
>       } else if (minSdkVersion >= 14) {
>         defaultConfig.versionCode += 8
>       }
>     }
> */
> {code}
> to:
> {code}
>     /*
>     ELSE NOTHING! DON'T MESS WITH THE VERSION CODE IF YOU DON'T HAVE TO!
> */
>     else if (!cdvVersionCode) {
>       def minSdkVersion = cdvMinSdkVersion ?: 
> privateHelpers.extractIntFromManifest("minSdkVersion")
>       // Vary versionCode by the two most common API levels:
>       // 14 is ICS, which is the lowest API level for many apps.
>       // 20 is Lollipop, which is the lowest API level for the updatable 
> system webview.
>       if (minSdkVersion >= 20) {
>         defaultConfig.versionCode = 
> Integer.parseInt(defaultConfig.versionCode + '9')
>       } else if (minSdkVersion >= 14) {
>         defaultConfig.versionCode = 
> Integer.parseInt(defaultConfig.versionCode + '8')
>       }
>     }
> {code}
> With this, the generated apk is not detected as a downgrade, and when I check 
> the app version in Settings of the Android device, it shows the correct 
> version number.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@cordova.apache.org
For additional commands, e-mail: issues-h...@cordova.apache.org

Reply via email to