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

I tried submitting another version of my android app to the google play store because the first one didnt have maps working. I later figured out I had to add an API key to my exp.json. However, I believe I can’t just update the app, I have to upload a new version to the app store. When I tried to upload the apk for the fixed maps it gave me this error “You need to use a different version code for your APK because you already have one with version code 1.”

3 Likes

hello! check out the instructions for updating, notice you can change the Android versionCode https://docs.expo.io/versions/v33.0.0/distribution/building-standalone-apps/#7-update-your-app

3 Likes

thank you :slightly_smiling_face:

On a detached app - the apk does not seem to be recognizing a change to the Android versionCode in the app.json file. ie: changed version code in app.json, then created apk file using ./gradlew assembleRelease from terminal.

I had to go into my app’s android > app > build.gradle file and change the versionCode there.

Maybe the is by design, or documented and I missed it, or is not documented - or maybe a bug.


I have tried w/ and without double-quotes.

“versionCode” : 2 and “versionCode”: “2”

"android": {
  "package": "com.bgbisland.babyjournal",
  "versionCode": 2,
  "icon": "./assets/icons/GoGoBabyJournal.png",
  "permissions": ["CAMERA", "READ_INTERNAL_STORAGE"]
},



"android": {
  "package": "com.bgbisland.babyjournal",
  "versionCode": "2",
  "icon": "./assets/icons/GoGoBabyJournal.png",
  "permissions": ["CAMERA", "READ_INTERNAL_STORAGE"]
},
2 Likes

On a detached app you will need to manually update the version code, just as you did. Standalone apps are built on Expo servers and use the manifest to set the version code. This does not happen when building a local detached app.

1 Like

Did anybody found the solution for this ( versionCode ) from the app.json file ?

1 Like

Hello,

I can’t update my android app on Google Play, it’s not a standalone app. I added:

“android”: {
“package”: “xxxx”,
“versionCode”: 2,
},

But when I inspect the resulted apk buit. I see that the manifest still contain version = 1

Could anyone help please?

Thanks

2 Likes

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