In this post, we are going to show you how to change the version code and version name of your Flutter app. Version code needs to update while uploading your APK or App bundle to Play Store. Otherwise, you will get the error below:
Play Store Error: You need to use a different version code for your APK or Android App Bundle because you already have one with version code ##.
We will explain the different methods to change the version code and version name of the app in Flutter. We recommend the first one to use.
Open pubspec.yaml file and get the line below:
Here, "1.0.0" is the version name and 1 after "+" is the version code. You can update them like below:
Note: Version code is an integer, no decimal is allowed on version code. While, you can use decimals on version name.
Open your_project/android/local.properties file and get the code below:
You can update them like below:
flutter.versionCode=2 //no deciaml, only integer
Open your_project/android/app/build.gradle file and get the lines below:
Now, update them with your own version code and version name like below:
In this way, you can update the version code and version name of your app in Flutter.