Nick Nick - 4 months ago 58
Android Question

Android - Cordova version code issue

This is quite a weird one.

Basically, I decided to switch from using to using cordova to build and compile my app (using ionic framework).

Everything is fine if I build an unsigned and unaligned app, but for production I have to sign and align the apk in order to upload it on the play store.

I have signed and aligned the apk properly, but when I tried to upload the apk, I got this error:

Your APK version code needs to be greater than 1457108319

Now, I read a couple of answers here on stack overflow saying that I just need to add this line in my project config.xml file:

<widget id="com.***********" android-versionCode="1457108319" version="5.0.0"

but the problem is that if I had this line of code, then gradle fails and I get this error:

Error: Error code 1 for command: cmd with args:
/s,/c,"c:\src\app-v5\platforms\android\gradlew cdvBuildRelease -b
c:\src\app-v5\platforms\android\build.gradle -Dorg.gradle.daemon=true

Hovewer, if I change the versionCode to a 6 digit code instead of 10, I get no error, but again, I can't upload it to the store because the versionCode number is less than the app already released.

How can I solve this? I really have no idea what to do.

Thanks a lot


I actually resolved this. I had to add to my config.xml file the following (in <widget>, right after version):

android-versionCode="{this needs to be replaced, in my case, by the current timestamp "

The downside is that I have to remember to put the new timestamp everytime for now.

I will, at some point, write some kind of script to do this for me.

Hope this helps someone