Quantcast
Channel: Intel Developer Zone Articles
Viewing all articles
Browse latest Browse all 3384

Android* and Crosswalk Cordova Version Code Issues

$
0
0

The release of Apache* Cordova* CLI 5 by the Apache Cordova project resulted in a change to how the android:versionCode parameter is calculated for apps built with the Intel® XDK using CLI 5. The android:versionCode is found in the AndroidManifest.xml file of every Android* and Android-Crosswalk APK; it is directly derived from the App Version Code field in the Build Settings section of the Projects tab:

If you have never published an app to an Android* store this change in behavior will have no impact on you. It might prevent side-loading an update to your app; in which case, simply uninstall the previously side-loaded app before installing your updated app.

New (CLI 5) App Version Code Algorithm for Android

Beginning with Cordova CLI 5, in order to maintain compatibility with standard Cordova, the Intel XDK no longer modifies the android:versionCode when building for Android-Crosswalk. Instead, the new Cordova CLI 5 encoding technique has been adopted for all Android builds. This change results in a discrepancy in the value of the android:versionCode that is inserted into your Android APK files when compared to building with CLI 4.1.2 (and earlier).

Here's what Cordova CLI 5 (Cordova-Android 4.x) does with the android:versionCode (App Version Code) number when you perform a Crosswalk build:

  • multiplies your android:versionCode by 10
  • adds 2 to the android:versionCode for Crosswalk ARM builds
  • adds 4 to the android:versionCode for Crosswalk x86 builds

Here's what Cordova CLI 5 (Cordova-Android 4.x) does with the android:versionCode (App Version Code) number when you perform a standard Android build (a non-Crosswalk build):

  • multiplies your android:versionCode by 10
  • adds 0 to the android:versionCode if the Minimum Android API is < 14
  • adds 8 to the android:versionCode if the Minimum Android API is 14-19
  • adds 9 to the android:versionCode if the Minimum Android API is > 19 (i.e., >= 20)

So this means the Android store will find the following android:versionCode values inside your built APK if you set the App Version Code field to one in the Build Settings section of the Projects tab:

  • an App Version Code = "1" in the Build Settings section of Intel XDK Projects tab results in:
  • android:versionCode = "10" for a regular Android build if the android:minSdkVersion is < 14
  • android:versionCode = "12" for an Android-Crosswalk embedded library ARM build
  • android:versionCode = "14" for an Android-Crosswalk embedded library x86 build
  • android:versionCode = "18" for a regular Android build if the android:minSdkVersion is 14-19
  • android:versionCode = "19" for a regular Android build if the android:minSdkVersion is > 19

NOTE: the Minimum Android* API field in the Build Settings section of the Projects tab corresponds to the value of the android:minSdkVersion number referenced in the bullets above.

This scheme results in an x86 APK file that contains a version code that is greater than the ARM APK file. This condition is necessary to insure that the Android store delivers the appropriate architecture APK file to the requesting device. In this scheme, the x86 APK version code is always two greater than the ARM APK version code.

NOTE: the Intel XDK build system generates two APK files (one marked x86 and one marked ARM) when you elect the shared Crosswalk build option, even though only one APK is required. The only difference between these two shared model APK files is the version code, which follows the same android:versionCode scheme as the embedded Crosswalk build option.

If you HAVE PREVIOUSLY PUBLISHED an Android-Crosswalk app to an Android store, built with the Intel XDK CLI 4.1.2 option (or earlier), the new android:versionCode scheme described above may impact your ability to publish an update of your app! If you encounter that case, add 6000 (six with three zeroes) to your existing App Version Code field in the Build Settings section of the Projects tab. Your Crosswalk apps that were built with CLI 4.1.2 used a system that adds 60000 and 20000 (six with four zeros and two with four zeroes) to the android:versionCode. That scheme is described in more detail, below.

If you have only published standard Android apps (non-Crosswalk) in the past, and are still publishing standard Android apps, you should not have to make any changes to the App Version Code field in the Android Builds Settings section of the Projects tab (other than increasing it by one for a new version).

NOTE:

  • Android API 14 corresponds to Android 4.0
  • Android API 19 corresponds to Android 4.4
  • Android API 20 corresponds to Android 5.0
  • CLI 5 and above (Cordova-Android 4.x) does not support Android 2.x or Android 3.x

Historic (CLI 4) App Version Code Algorithm for Android

In the past (CLI 4.1.2 and earlier), standard Cordova did not modify the Android version code, so the android:versionCode found in your Android APK by the store was identical to the value provided in the App Version Code field. In order to support the submission of multiple Android-Crosswalk APK files (e.g., ARM and x86) to an Android store, the Intel XDK build system did modify the version code for Android-Crosswalk embedded builds (and only for Android-Crosswalk embedded builds, Crosswalk shared and regular Android build version codes were not modified by the build system).

The "historic" behavior of the Intel XDK build system regarding the Android version code that was inserted into your APK files, when built using CLI 4.1.2 (or earlier) was:

  • no change to the version code for regular Android builds (android:versionCode = App Version Code)
  • no change to the version code for Android-Crosswalk shared library builds
  • add 60000 to the version code for Android-Crosswalk x86 embedded library builds
  • add 20000 to the version code for Android-Crosswalk ARM embedded library builds

So this meant that you would find the following android:versionCode values inside your APK files, if you had set the App Version Code field to a value of one in the Build Settings section of the Projects tab and set the CLI version to 4.1.2:

  • an App Version Code = "1" in the Build Settings section of Intel XDK Projects tab results in:
  • android:versionCode = "1" for a regular Android build
  • android:versionCode = "1" for an Android-Crosswalk shared library build
  • android:versionCode = "20001" for an Android-Crosswalk embedded library ARM build
  • android:versionCode = "60001" for an Android-Crosswalk embedded library x86 build

This scheme was used to insure that the x86 APK contained a higher version code than the equivalent ARM APK, and also so that both APKs contained larger version codes than a generic Android APK that you might use, for example, to provide an app to Android 2.x and 3.x devices (because Android-Crosswalk requires at least Android 4.0). Putting a larger version code into the x86 APK makes sure that the Android store will deliver the x86 APK to x86 devices, rather than incorrectly delivering an ARM APK to x86 devices.


Viewing all articles
Browse latest Browse all 3384

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>