Building with cordova for android creates wrong version code

executing the cordova build --release android creates apk with version 70 code. in the config.xml file, for the widget I installed it as

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

How can I get cordova-cli to build apk with version 7 code?

Running aapt.exe l -a on the generated apk shows that A: android:versionCode(0x0101021b)=(type 0x10)0x46 0x46 is 70 if I am jarsigner apk and zipalign and upload, google also tells me that the version code is equal 70.

+6
source share
2 answers

I found the answer to my problem in that in the platforms/android/build.gradle , on line 178,

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

at the end means that + "0" thus changes the version code from 7 to 70. Extracting + "0" at the end and changing line 178 to the next solution to 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

+7
source

I had the same problem, I am using Cordova 4.3.0. My version code in AndroidManifest.xml was "1", and the Code version in .apk passed as "12". If you look at a piece of code after the line you are referring to, creating multiple versions will add β€œ2” for arm7 and β€œ4” for x86. I kinda understand why this was done, but it seems to me that it is better to let the developers determine the version that they want.

+5
source

Source: https://habr.com/ru/post/989157/


All Articles