简体   繁体   中英

Cordova 6 android version issues

I have a published app on play store. The problem I am facing is that it looks like Cordova 6 (I just upgraded to 6.5) has changed release version generation. Here is my config.xml

<widget android-packageName="com.myapp" id="com.myapp" ios-CFBundleIdentifier="com.myapp"  version="1.2.38" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">

I build both native and crosswalk builds for my app with the following rules:

  • if API version >=21, install native version cordova build android --release -- --minSdkVersion=21
  • For other versions, install crosswalk version cordova plugin add cordova-plugin-crosswalk-webview && cordova build android --release

Here is the version code of my published apps: 在此处输入图片说明

Now, after upgrading cordova to 6.5, when I did my build process, changing version to 1.2.39 the crosswalk versions used the right version code 102392 for ARM and 102394 for x86. However, the native version now has the version code 10239

This causes an upgrade problem because my current native code version is "102389" which is > "10239"

I tried adding android-versionCode in my config.xml like this:

android-versionCode="102390" version="1.2.39"

This however results in

  1. Xwalk x86 version = 1023904
  2. Xwalk arm version = 1023902
  3. Native version = 102390

As you see the Xwalk versions now have a much larger number than my existing production builds. This is also not right, because the Xwalk versions will take preference over the native version even in devices with SDK >=21 which is undesirable. How do I fix this?

The core problem is that cordova xwalk builds multiple arch files and the version calculation is multiplied by 10 and the platform code added. The native version is built as one package and is not multiplied by 10. Older versions of cordova seem to have been handling this correctly.

I've implemented a workaround by adding a manual version code just for the native build. I really shouldn't have to do this. It works, but I am not going to mark this accepted hoping I'll get better answers.

Here is the additional code for the native (non XWalk build)

APPVER=`cat config.xml | grep "widget " | sed 's/.* version=\"\([^\"]*\)\" xmlns.*/\1/'`
a=( ${APPVER//./ } )
vcode="$(((a[0]*10000+a[1]*100+a[2])))9"
cordova build android --release -- --minSdkVersion=21 --versionCode=${vcode}

This now produces version codes that are as intended: 在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM