[ 
https://issues.apache.org/jira/browse/CB-11742?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Joe Bowser resolved CB-11742.
-----------------------------
    Resolution: Won't Fix

Use the android-versionCode preference to set your version code on the build.  

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