使用cordova for android构建错误的版本代码

时间:2015-06-15 20:23:48

标签: android cordova

运行命令cordova build --release android会在config.xml文件中生成一个版本代码为70的apk,对于我将其设置为

的小部件
<widget id="com.example.myapp"
        android-versionCode="7"
        version="0.9.1"
        >

如何让cordova-cli构建版本代码为7的apk?

在生成的apk上运行aapt.exe l -a显示A: android:versionCode(0x0101021b)=(type 0x10)0x46 0x46为70,如果我jarsigner的apk,并且zipalign和上传,谷歌也告诉我版本代码是70。

2 个答案:

答案 0 :(得分:7)

我在platforms/android/build.gradle第178行

下找到了我的问题的答案
versionCode cdvVersionCode ?: Integer.parseInt("" + privateHelpers.extractIntFromManifest("versionCode") + "0")

最后是+ "0"因此将我的版本代码从7变为70.删除末尾的+ "0"并将第178行更改为以下内容解决了这个问题。

versionCode cdvVersionCode ?: Integer.parseInt("" + privateHelpers.extractIntFromManifest("versionCode"))

在生成的apk上运行aapt.exe l -a现在显示A: android:versionCode(0x0101021b)=(type 0x10)0x7

答案 1 :(得分:5)

I had the same issue, I'm using Cordova 4.3.0. My versionCode in the AndroidManifest.xml was "1" and the versionCode in the .apk was coming through as "12". If you look at the chunk of code after the line you reference, building multiple versions will append a "2" for arm7 and a "4" for x86. I sort of see why this was done, but it seems to me it's better to let developers determine the versionCode they want.