简体   繁体   English

Cordova 6 android版本问题

[英]Cordova 6 android version issues

I have a published app on play store. 我在Play商店有一个已发布的应用程序。 The problem I am facing is that it looks like Cordova 6 (I just upgraded to 6.5) has changed release version generation. 我面临的问题是Cordova 6(我刚刚升级到6.5)看起来已经更改了发行版本。 Here is my config.xml 这是我的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 如果API版本> = 21,则安装本地版本cordova build android --release -- --minSdkVersion=21
  • For other versions, install crosswalk version cordova plugin add cordova-plugin-crosswalk-webview && cordova build android --release 对于其他版本,请安装crosswalk版本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. 现在,在将cordova升级到6.5之后,当我执行构建过程时, 将版本更改为1.2.39 ,人行横道版本对ARM使用了正确的版本代码102392,对于x86使用了正确的代码102394。 However, the native version now has the version code 10239 但是,本机版本现在具有版本代码10239

This causes an upgrade problem because my current native code version is "102389" which is > "10239" 这会导致升级问题,因为我当前的本机代码版本是“ 102389”,即>“ 10239”

I tried adding android-versionCode in my config.xml like this: 我试图像这样在我的config.xml中添加android-versionCode:

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

This however results in 但是这导致

  1. Xwalk x86 version = 1023904 Xwalk x86版本= 1023904
  2. Xwalk arm version = 1023902 Xwalk手臂版本= 1023902
  3. Native version = 102390 本机版本= 102390

As you see the Xwalk versions now have a much larger number than my existing production builds. 如您所见,Xwalk版本现在的数量比我现有的生产版本大得多。 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. 这也不对,因为即使在SDK> = 21的设备中,Xwalk版本也会优先于本机版本,这是不希望的。 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. 核心问题是cordova xwalk会构建多个arch文件,并且版本计算将乘以10,并添加平台代码。 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. 本机版本是作为一个程序包构建的,不会乘以10。老版本的cordova似乎已正确处理了此问题。

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) 这是本机(非XWalk构建)的附加代码

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: 现在,这将产生预期的版本代码: 在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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