Flutterプロジェクトの開発では自動的にパッケージ化されたバージョン番号に変更する必要がある場合があり、対応するAndroidとiOSのプロジェクトに各時間は、次のように変更することは非常に便利ではありませんが、Googleの後に一度、次の方法を試してみてくださいパッケージングバージョン番号の自動パッケージングで変更することができます。
アンドロイドプロジェクト
プロジェクト構成
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
throw new GradleException("versionCode not found. Define flutter.versionCode in the local.properties file.")
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
throw new GradleException("versionName not found. Define flutter.versionName in the local.properties file.")
}
apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion 27
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://..///-.ml).
applicationId "com.example.hello"
minSdkVersion 16
targetSdkVersion 27
versionCode flutterVersionCode.toInteger()
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
}
}
}
梱包コマンド
必要なものに応じて、-build-name または --build-number をパッケージ・コマンドに追加してください。
flutter build apk --build-name=1.0.3
flutter build apk --build-number=3
flutter build apk --build-name=1.0.3 --build-number=3
iOS
プロジェクト構成
CFBundleShortVersionString$(FLUTTER_BUILD_NAME)プロジェクト・ディレクトリの下にあるinfo.plistファイルを見つけ、ソースとして開き、キーの値を,CFBundleVersionに設定します。$(FLUTTER_BUILD_NUMBER)
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://..//-..td">
<plist version="1.0">
<dict>
...
<key>CFBundleShortVersionString</key>
<string>$(FLUTTER_BUILD_NAME)</string>
<key>CFBundleVersion</key>
<string>$(FLUTTER_BUILD_NUMBER)</string>
...
</dict>
</plist>
Current Project Version(FLUTTER_BUILD_NUMBER) プロジェクトのビルド設定で、versioningを検索し、下図に示すように値をtoに設定します。
梱包コマンド
flutter build ios --build-name=1.0.3





