versionCode and versionName - Android APK issues

  • Hi,

    So I've been using the version property in C3 incrementally every time I roll out a new update, using a 0.xxx format. I honestly couldn't imagine this would cause any problems for me, but apparently it can.

    So as I'm nearing release of my app, the last build that I uploaded was 0.998 - all seemed great, the light was there at the end of the tunnel, I was about to celebrate as I uploaded 1.0 in readiness for my app's launch, when the Play Store decided to slap me down with vigour.

    Turns out, when our apps are exported, the version number is used to generate the versionCode and versionName for our APKs. The problem I'm having is that the versionCode for 0.998 is 9980000 while the versionCode for 1.0 is 1000000. Now, I'm not 100% sure why this is happening, but I think it has something to do with me not following a 0.x.x.x version structure when I first started.

    Essentially, I want versionName to be 1.0 and versionCode to be 10000000 (higher than the previous build). As VersionCode is what the Play Store uses to roll out the highest version, it can't be less than the previous one.

    I'm hoping there's an easy way to change versionCode, but I haven't been able to do it in C3.

    My other option, which I'm really loathe to do, is to export with a version of 10.0 - that will give me a higher code, but users will see the app version and that's not really something I want. While I'm on this topic as well, I noted at developer.android.com/studio/publish/versioning that it states that

    the versionCode value does not necessarily have a strong resemblance to the app release version that is visible to the user (see versionName, below). Apps and publishing services should not display this version value to users.

    ^ Based on that, I feel like maybe there should be two separate fields in C3 for these values.

    Here are the screens from the Play Store that show my issues between 0.998 and 1.0 converting to codes.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • The version code is calculated from the version number. It will take the following formats:

    • MAJOR
    • MAJOR.MINOR
    • MAJOR.MINOR.MAINTENANCE
    • MAJOR.MINOR.MAINTENANCE.BUILD

    We then use the sum BUILD + (MINOR * 100) + (MINOR* 10000) + (MAJOR * 1000000) to create the version code. So in practise it's not advisable to increase any of those values higher than 99. Obviously with your naming variation this is not ideal. 0.998 is the same as 9.98 which is why your having problems going to 1.0.

    You can work around this by going straight to version 10.0 or if your building via android studio/cordova you can edit the version code.

  • Hey Nepeo

    As I mentioned, I really don't want my release version number to be 10.0 in the Play Store as I think that's confusing for users.

    I might try changing it in Android Studio, though I have no experience using that. As it's only a minor change, hopefully it's pretty straightforward. Still, kind of annoying that I'll have to do this every time I release a new build from now on.

  • Yeah its unfortunate, and an unpleasant gotcha to experience after a large number of revisions. The reasoning behind this is Android is the only platform with 2 separate fields for a version number, Cordova also hit this problem and just added a thing that generates the versionCode automatically from the version number. We just copied their behaviour. Instead of adding a property to the project that is only used on Android.

    Another thing you could do is to treat the right hand side as a build number, that doesn't reset when you change the major version. So your next version would be 1.1000.

    It's not uncommon to have a behaviour like this, I used to work on an application where we had a 3 digit build value at the end, and used even values for Android and odd for Android.

    I'll have a chat with the others what we think the best solution for this is, I think we should be able to provide an override for the versionCode value somewhere and an associated warning about the sum we use for the default value.

  • It would definitely be nice if there was an override somewhere... For now, I'll play around with Android Studio. I still have a couple of weeks until release date, otherwise I might be panicking over this XD

    Cheers

  • Couple of pointers for Android studio. First is that due to a Gradle change projects won't build out of the box. Find the error message that mentions "minSDK", when you select it a link appears in the description to "refactor" it. Which resolves the problem.

    Second thing is you can find the versionCode in the AndroidManifest.xml file. Good luck!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)