react-nativemobilebuildexpo

Expo creates build with wrong version code


I'm trying to deploy a new version of my app on Google Store, but expo creates the build with the same version code.

I incremented the versionCode from 1 to 2.

"android": {
  "package": "some-package",
  "versionCode": 2,
  "adaptiveIcon": {
    "foregroundImage": "./assets/app-icon.png",
    "backgroundColor": "#FFFFFFFF"
  }
}

I also incremented the version property.

"expo": {
  "name": "app-name",
  "slug": "app-name",
  "version": "2.0.0",
  ...
}

When I run eas build --platform android, the build is successful, but the version and version code are the following:

Profile SDK Version Version Version Code
production 48.0.0 1.0.1 1

Version Information

The Version should be 2.0.0 and the Version code should be 2.

What should I do to fix this?


Solution

  • I had this problem as well but try to upload your build on Google and it should display the correct versions. If not, insert the following into your

    Android/app/build.gradle file

    def version = new File("$rootDir/../package.json")
    def packageJson = new JsonSlurper().parseText(version.text)
    def actualVersion = packageJson.version
    def actualVersionCode = packageJson.versionCode
    
    defaultConfig {
        versionCode actualVersionCode
        versionName actualVersion
    }
    

    Note that this code gets its values from package.json

    It should display the following result but once you upload your build to Google Play Store, the version and version code is present!

    enter image description here