Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

flutter version code is different from version code in google play console #49544

Open
maheshmnj opened this issue Jan 27, 2020 · 12 comments
Open
Labels
a: release Challenges faced when attempting to productionize an app c: proposal A detailed proposal for a change to Flutter P3 Issues that are less important to the Flutter project platform-android Android applications specifically t: gradle "flutter build" and "flutter run" on Android team-android Owned by Android platform team tool Affects the "flutter" command-line tool. See also t: labels. triaged-android Triaged by Android platform team

Comments

@maheshmnj
Copy link
Member

maheshmnj commented Jan 27, 2020

When uploading app to playstore I understand that we need our app to have a unique version code for each build and in flutter the version code is said to be what follows + in pubspec.yaml.
e.g version: 1.0.0+3 has a version code of 3 but when I upload my split apk's built using
flutter build apk --split-per-abi to google play console has version code as 4003,2003&1003

image

The problem is the version codes get huge when using split apks and it doesn't seem to respect the version number specified in pubspec.yaml.

fastlane/fastlane#15936 (comment)

@VladyslavBondarenko
Copy link

Related to #39817

@VladyslavBondarenko VladyslavBondarenko added t: gradle "flutter build" and "flutter run" on Android tool Affects the "flutter" command-line tool. See also t: labels. labels Jan 27, 2020
@jmagman jmagman added the platform-android Android applications specifically label Jan 27, 2020
@jmagman jmagman added this to Awaiting triage in Tools - Gradle review via automation Jan 27, 2020
@jonahwilliams
Copy link
Member

This is the intended behavior of split APKs, for more information see:

https://developer.android.com/studio/build/configure-apk-splits#configure-APK-versions

Tools - Gradle review automation moved this from Awaiting triage to Engineer reviewed Feb 8, 2020
@sathya4code
Copy link

Hi, I am also facing the same issue. For some security reason i am checking the app version and send it to backend. In my backend i have the version code like 5. But when i am reading the version code using package_info i am getting the version code like 1005, 2005 and 4005. How can i get the exact version code? Any idea?

Note: i cant use bundle. we don't have access for certificate file.

@sathya4code
Copy link

Hi, I am also facing the same issue. For some security reason i am checking the app version and send it to backend. In my backend i have the version code like 5. But when i am reading the version code using package_info i am getting the version code like 1005, 2005 and 4005. How can i get the exact version code? Any idea?

Note: i cant use bundle. we don't have access for certificate file.

Hi.. Any update regarding this?

@koraxis
Copy link

koraxis commented May 6, 2020

Hi, --split-per-abi doesnt work with the suggestions from https://developer.android.com/studio/build/configure-apk-splits#configure-APK-versions.

When you add split{} to the build.gradle and try to customize the versioning, --split-per-abi is still using its own default behavior of generating the versionCode

@danybuoy
Copy link

danybuoy commented May 9, 2020

Hey, running into this too. Seems like the "intended behaviour" is for split apks to use the version code generated by flutter.gradle check line 631. This seems to override any changes I make to the version code in my app/gradle, is it possible to make this optional? @jonahwilliams

@VladyslavBondarenko VladyslavBondarenko added the c: proposal A detailed proposal for a change to Flutter label May 11, 2020
@jmagman jmagman added the P3 Issues that are less important to the Flutter project label Aug 18, 2020
@maheshmnj
Copy link
Member Author

maheshmnj commented Apr 20, 2021

Hey, running into this too. Seems like the "intended behaviour" is for split apks to use the version code generated by flutter.gradle check line 631. This seems to override any changes I make to the version code in my app/gradle, is it possible to make this optional? @jonahwilliams

but the problem with split apk is the build number gets huge as pointed here #49544 (comment)

nextime I upload a build the build number has to be more than 4003

@yohom
Copy link

yohom commented Jun 30, 2021

Hey, running into this too. Seems like the "intended behaviour" is for split apks to use the version code generated by flutter.gradle check line 631. This seems to override any changes I make to the version code in my app/gradle, is it possible to make this optional? @jonahwilliams

I made a workaround by overriding the split logic in flutter.gradle. Add this code in your android {} block. You can try it.

project.android.applicationVariants.all { variant ->
    variant.outputs.each { output ->
        output.versionCodeOverride = variant.versionCode
    }
}

@maheshmnj
Copy link
Member Author

The question right now is if a user wishes to deploy split apks to the playstore, How should the app versioning be handled? Since the version number is huge when uploaded to playstore.

@maheshmnj maheshmnj added the a: release Challenges faced when attempting to productionize an app label Jun 21, 2022
@yusuphwickama
Copy link

yusuphwickama commented Jul 4, 2022

I made a workaround by overriding the split logic in flutter.gradle. Add this code in your android {} block. You can try it.

project.android.applicationVariants.all { variant ->
    variant.outputs.each { output ->
        output.versionCodeOverride = variant.versionCode
    }
}

Here is a working version for android/app/build.gradle

android {
        ...        
        defaultConfig {
                project.android.applicationVariants.all { variant ->
                        variant.outputs.each { output ->
                             output.versionCodeOverride = flutterVersionCode.toInteger()
                         }
                }
        }
}

@Kingtous
Copy link

Kingtous commented Jun 24, 2023

Hey, I'm facing the same issues from version code. The app store within our countries can only support APK. And we need to provide both of arm and arm64 version of our app with the same version code. --split-per-abi is a convenient way to build arm and arm64 artifacts in only one command, but the version code is suffixed with 1000 for arm and 2000 for arm64, and it's really strange and rejected by the app store. I understand it may be an intended behavior, I just describe what I has encountered during uploading my app to the app store :)

@mhkarami
Copy link

here is the solution :
https://stackoverflow.com/a/78395354/8660482

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a: release Challenges faced when attempting to productionize an app c: proposal A detailed proposal for a change to Flutter P3 Issues that are less important to the Flutter project platform-android Android applications specifically t: gradle "flutter build" and "flutter run" on Android team-android Owned by Android platform team tool Affects the "flutter" command-line tool. See also t: labels. triaged-android Triaged by Android platform team
Projects
Tools - Gradle review
  
Engineer reviewed
Development

No branches or pull requests