バージョン コード 1 はすでに使用されているというプロンプトを解決して、別のバージョン コードを試してください。

シーン

最後のバージョンが最初のデフォルト バージョン 1.0.0 であるため、flutter build appbundleパッケージ化された aabを使用する場合。
そこで今回はバージョン名の後ろに 1 を追加してパッケージ化しました。

name: flutter_demo
description: A new Flutter application for Flutter demo

# The following line prevents the package from being accidentally published to
# pub.dev using `pub publish`. This is preferred for private packages.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev

# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# In Android, build-name is used as versionName while build-number used as versionCode.
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.0.0+1

にアップロードするとGoogle Play、次のエラー メッセージが表示されました。

Version code 1 has already been used. Try another version code.

ここに画像の説明を挿入

原因分析

まず最初に、Flutter のバージョンがどのように管理されるかを理解する必要があります。

Flutter によってパッケージ化されたバージョン名とバージョン番号は、デフォルトで pubspec.yaml のバージョンから読み取られます。その値を更新するだけです。

フォーマットは

バージョン:ABC+X

Android版の場合、app/build.gradleでバージョン番号の管理を設定します。

android{
    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.exmaple.demo"
        minSdkVersion 21
        targetSdkVersion 31
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
    }
}

ABC は verisonName を表します。たとえば、デフォルトの初期値は 1.0.0 です。X は
versionCode を表し、デフォルト値は 1 から始まり、順次累積されます。
デフォルトのアプリの versionName は 1.0.0、versionCode は 1 です。

解決

デフォルトの versionName では、versionCode が後で追加されない場合、versionCode はデフォルトで 1 になるため、1.0.0と の1.0.0+1間に違いはありません。

versionCode の後にさらに大きな数値を追加するだけです。たとえば +2。

name: flutter_demo
description: A new Flutter application for Flutter demo

# The following line prevents the package from being accidentally published to
# pub.dev using `pub publish`. This is preferred for private packages.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev

# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# In Android, build-name is used as versionName while build-number used as versionCode.
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
# 1更改为2
version: 1.0.0+2

再パッケージ化してアップロードすると、Google Play に正常にアップロードできるようになります。

おすすめ

転載: blog.csdn.net/adojayfan/article/details/126409373