😵
【Flutter】【Android】 fluttter build appbundle(リリース作業) でエラー ERROR: R8...
エラー内容
ERROR: R8: java.lang.IllegalArgumentException: Provided Metadata instance has version 2.1.0, while maximum supported version is 2.0.0. To support newer versions, update the kotlinx-metadata-jvm library.
対応
1, 各種設定、ライブラリのバージョンを最新に更新する
// {YourApp}/android/settings.gradle ファイル
// 旧
plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version "8.3.0" apply false
// START: FlutterFire Configuration
id "com.google.gms.google-services" version "4.3.15" apply false
id "com.google.firebase.crashlytics" version "2.8.1" apply false
// END: FlutterFire Configuration
id "org.jetbrains.kotlin.android" version "2.1.20" apply false
}
⬇️
// 新
plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version "8.11.1" apply false // 更新(AGPバージョン)
// START: FlutterFire Configuration
id "com.google.gms.google-services" version "4.4.3" apply false // 更新
id "com.google.firebase.crashlytics" version "3.0.4" apply false // 更新
// END: FlutterFire Configuration
id "org.jetbrains.kotlin.android" version "2.1.20" apply false
}
2, AGP(id "com.android.application"の値)に、Gradleを合わせる
次に、
AGPバージョン(id "com.android.application"の値)、と、必須Gradleバージョン を各バージョンごとに設定が必要で、
AGP(8.11.1)なら、Gradle(8.13以上)なので、そちらも合わせて設定。
下記ファイルで、Gradleバージョンを設定
// {YourApp}/gradle/wrapper/gradle-wrapper.properties ファイル
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-all.zip
で、リリースビルドOK。動作確認して、挙動に問題ないことを確認して、完了。
エラーログ(全文)
ERROR: R8: java.lang.IllegalArgumentException: Provided Metadata instance has version 2.1.0, while maximum supported version is 2.0.0. To support newer versions, update the kotlinx-metadata-jvm library.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:minifyReleaseWithR8'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.R8Task$R8Runnable
> Compilation failed to complete
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.
BUILD FAILED in 27s
Running Gradle task 'bundleRelease'... 27.7s
Gradle task bundleRelease failed with exit code 1
Discussion