[英]building with cordova for android creates wrong version code
running the command cordova build --release android
produces an apk that has a version code of 70. in the config.xml file, for the widget i have set it as 运行命令cordova build --release android
在config.xml文件中生成一个版本代码为70的apk,对于我将其设置为的小部件
<widget id="com.example.myapp"
android-versionCode="7"
version="0.9.1"
>
How do I get cordova-cli to build an apk with version code 7? 如何让cordova-cli构建一个版本号为7的apk?
Running aapt.exe l -a
on the generated apk shows A: android:versionCode(0x0101021b)=(type 0x10)0x46
0x46 being 70, if I jarsigner the apk, and zipalign and upload, google also tells me the version code is 70. 在生成的apk上运行aapt.exe l -a
显示A: android:versionCode(0x0101021b)=(type 0x10)0x46
0x46是70,如果我jarsigner的apk,并且zipalign和上传,谷歌也告诉我版本代码是70 。
I found the answer to my problem in that under platforms/android/build.gradle
, on line 178, 我在第178行的platforms/android/build.gradle
下找到了我的问题的答案,
versionCode cdvVersionCode ?: Integer.parseInt("" + privateHelpers.extractIntFromManifest("versionCode") + "0")
at the end is that + "0"
thus turning my version code from 7 to 70. Removing the + "0"
at the end and changing line 178 to the following solved this problem. 最后是+ "0"
从而将我的版本代码从7变为70.删除末尾的+ "0"
并将行178更改为以下解决了这个问题。
versionCode cdvVersionCode ?: Integer.parseInt("" + privateHelpers.extractIntFromManifest("versionCode"))
Running aapt.exe l -a
on the generated apk now shows A: android:versionCode(0x0101021b)=(type 0x10)0x7
在生成的apk上运行aapt.exe l -a
现在显示A: android:versionCode(0x0101021b)=(type 0x10)0x7
I had the same issue, I'm using Cordova 4.3.0. 我有同样的问题,我正在使用Cordova 4.3.0。 My versionCode in the AndroidManifest.xml was "1" and the versionCode in the .apk was coming through as "12". AndroidManifest.xml中的versionCode为“1”,而.apk中的versionCode为“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. 如果你在引用的行之后查看代码块,构建多个版本将为arm7添加“2”,为x86添加“4”。 I sort of see why this was done, but it seems to me it's better to let developers determine the versionCode they want. 我有点明白为什么这样做了,但在我看来,最好让开发人员确定他们想要的versionCode。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.