Flutter: upgrade the version code for play store

Pondikpa Tchabao picture Pondikpa Tchabao · Dec 1, 2018 · Viewed 50.5k times · Source

i have published an application on the play store with flutter, now i want to upload a new version of the application. I am trying to change the version code with:

flutter build apk --build-name=1.0.2 --build-number=3

or changing the local.properties like this

 flutter.versionName=2.0.0
 flutter.versionCode=2
 flutter.buildMode=release

but everytime i get error on the playstore

You must use a different version code for your APK or your Android App Bundle because the code 1 is already assigned to another APK or Android App Bundle.

Answer

Rohan Taneja picture Rohan Taneja · Jul 10, 2019

version in pubspec.yaml file

Update version:A.B.C+X in pubspec.yaml.

For Android:

A.B.C represents the versionName such as 1.0.0.

X (the number after the +) represents the versionCode such as 1, 2, 3, etc.

Do not forget to execute flutter packages get, flutter build or flutter run after this step, because: When you run flutter packages get after updating this version in the pubspec file, the versionName and versionCode in local.properties are updated which are later picked up in the build.gradle (app) when you build your flutter project using flutter build or flutter run which is ultimately responsible for setting the versionName and versionCode for the apk.

For iOS:

A.B.C represents the CFBundleShortVersionString such as 1.0.0.

X (the number after the +) represents the CFBundleVersion such as 1, 2, 3, etc.

Do not forget to execute flutter packages get, flutter build or flutter run after this step