Flutter: upgrade the version code for play store

我的未来我决定 提交于 2020-05-24 08:13:07

问题


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.


回答1:


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.

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.




回答2:


Figured this one out. Documentation is not straight forward

in your pubspec.yaml change the version like this

version: 1.0.2+2

where the stuff is VER_NAME+VER_CODE




回答3:


Solution:

Inside pubspec.yaml add this (probably after description, same indentation as of description, name etc...):

version: 2.0.0+2

Then do packages get inside flutter local directory (Do not forget to do this)

Explanation:

Everything before plus is version name and after is version code. So here the version code is 2 and name is 2.0.0. Whenever you give an update to the flutter app make sure to change the version code compulsorily!

Addtional Info:

Whenever android app is built, build.gradle inside android/app/ looks for version code and name. This usually lies in local.properties which is changed every time you change flutter pubspec.yaml




回答4:


Updating the app’s version number The default version number of the app is 1.0.0. To update it, navigate to the pubspec.yaml file and update the following line:

version: 1.0.0+1

The version number is three numbers separated by dots, such as 1.0.0 in the example above, followed by an optional build number such as 1 in the example above, separated by a +.

Both the version and the build number may be overridden in Flutter’s build by specifying --build-name and --build-number, respectively.

In Android, build-name is used as versionName while build-number used as versionCode. For more information, see Version your app in the Android documentation.




回答5:


First one change flutter version in pubspec.yaml example `version 1.0.3+4

In case of android go to local.properties than change version name and code same like flutter version code and name.

In case of Ios go to generated.xcconfig than chnage FLUTTER_BUILD_NAME=1.0.3 FLUTTER_BUILD_NUMBER=4`




回答6:


Docs says the build args should override pubspec.yml:

Both the version and the build number may be overridden in Flutter’s build by specifying --build-name and --build-number, respectively.

https://flutter.dev/docs/deployment/android#updating-the-apps-version-number



来源:https://stackoverflow.com/questions/53570575/flutter-upgrade-the-version-code-for-play-store

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!