How do I deal with version codes for APKs in Android?

Hey @botmane,

We refer to the built apks / ipas that get submitted to app stores as “standalone” apps.
I suspect you’re seeing a mismatch between the built app and your latest publish. Try publishing first, and then building again or check out https://docs.expo.io/versions/latest/guides/advanced-release-channels.html#what-version-of-the-app-will-my-users-get

1 Like

All the links on here explaining how to update the version code for the google play APK are dead. Any current links explaining this? Resbumitting to the google play store for the first time and keep on seeing “You need to use a different version code for your APK because you already have one with version code 1.”

Hey @markmiller21,

You’ll want to increment your versionCode key in your app.json. https://docs.expo.io/versions/latest/workflow/configuration#versioncodeversion-number-required-by-google-play-increment-by-one-for-each-release-must-be-an-integer-httpsdeveloperandroidcomstudiopublishversioninghtml

2 Likes

Hi @adamjnav,

Thanks for you input, I have the same issue and have tried what you’ve suggested. When I’m trying to build the stand alone app I get the following error message:

Error: Problem validating fields in app.json. See https://docs.expo.io/versions/v25.0.0/guides/configuration.html.
• should NOT have additional property ‘versionCode’.

I’m really struggling to work out how to solve this one. If I change the version, the Play store tells me that the version code is still the same… When I add in versionCode to app.json I get the following error:

Error: Problem validating fields in app.json. See https://docs.expo.io/versions/v25.0.0/guides/configuration.html.
• should NOT have additional property ‘versionCode’.
Warning: Not using the Expo fork of react-native. See https://docs.expo.io/.
Couldn’t publish because errors were found. (See logs above.) Please fix the errors and try again.

If anyone knows how to fix this I would be very grateful for your help.

@jamie.hewitt Can you share your app.json? You can dm me if you don’t want to post it in here.

@adamjnav Thanks a lot for your response, I’ve attached a screenshot of the app.json file

json%20screenshotPNG

I don’t see versionCode in there at all? It should be under your android key.

"android": { 
   "package": "com.jamiehewitt.tubehistory",
   "versionCode": 2
}
3 Likes

Hi @adamjnav, thanks for your response. I removed it as it wasn’t working, but when it was in there it was directly under “version” so it sounds like I put it in the wrong place. I’ll try again.

https://docs.expo.io/versions/v31.0.0/workflow/configuration.html#android

shows the parameter versionCode which needs to be configured. It is not clear in the doc.

  /*
      Version number required by Google Play. 
      Increment by one for each release. 
      Must be an integer. 
      developer.android.com/studio/publish/versioning.html

      ExpoKit: this is set in `android/app/build.gradle`.
    */
    "versionCode": NUMBER,

If you are using expo build:android
use version code as numeric value as mentioned in below code

“android”: {
“package”: “com.test.app”,
“versionCode”: 2,
“permissions”: [“CAMERA”,“READ_EXTERNAL_STORAGE”,“READ_CALENDAR”, “WRITE_EXTERNAL_STORAGE”]
},

2 Likes

Is my understanding correct that we have to publish before building the .apk?
So then, users with an old .apk get new JavaScript before they get an APK update?
That doesn’t seem right… Is there a way to tie the published JavaScript to a certain versionCode, to make sure that users of old APK’s stay on old JavaScript?

Yes, you need to publish before or while building.
However, whether or not the existing APKs will download the new JavaScript depends on things like the SDK version number etc. This flowchart might help.

If this is not what you want there are a few things you can do.

Look into release channels:

https://docs.expo.io/versions/latest/distribution/release-channels/
https://docs.expo.io/versions/latest/distribution/advanced-release-channels/#promoting-a-release-to-a-new-channel

Also, using the Updates module you can disable automated updates and manually check for updates yourself. You should be able to use the returned manifest to decide whether to download the update or not.

See also the following posts on versioning:

This one and this one are more relevant to ejected apps, but the description of how he uses release channels might still be useful.

Thanks for your reply. So, basically, when a new SDK is used, Expo will ensure that old instances of the app that use the old SDK don’t pull in that JavaScript. But in all other cases, we’d have to work around it ourselves.

problem fixed here : https://youtu.be/GZrxA5SjXJY

My Problem is not solved Yet from this video or any link. I changed my version from 1.0.0 to 2.0.0 in my app.json
and made a new apk but it is not uploading that apk till now. I searched a lot about this problem But cannot find the answer till now. If any one could help I will be Glad.

Make sure you update versionCode in app.json not version.

in app.json:

    "android": {
      "package": "com.yourcompany.yourappname",
      "versionCode": 1
    }

Yeah I m running Version in app.json I will try and respond asap If it works :blush:

It worked @nxtra. Anybody Who is facing this problem should add a new line inside
“android”: {
“package”: “com.yourcompany.yourappname”,
“versionCode”: 2
}
If VersionCode is already there just change it to the version you want THis works I just uploaded my app on playstore You can do it

Your app currently targets API level 29 and must target at least API level 30 to ensure it is built on the latest APIs optimized for security and performance. Change your app’s target API level to at least 30, that error is still distruct me please help me