Uploaded image for project: 'Apache Cordova'
  1. Apache Cordova
  2. CB-11742

After upgrading to version 6.3.1, apps won't install in Android because they are detected as DOWNGRADE

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Won't Fix
    • 6.3.1
    • None
    • cordova-android
    • Developing on Windows 8.1 with node v5.1.0, cordova 6.3.1 for android

    Description

      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:

          /*
      
          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
            }
          }
      */
      

      to:

          /*
      
          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')
            }
          }
      

      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.

      Attachments

        Activity

          People

            Unassigned Unassigned
            dmborque David Martinez Borque
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: