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
<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?
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.
I found the answer to my problem in that under platforms/android/build.gradle
, on line 178,
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.
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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With