Flutter升级到2.10后无法编译的错误解决方案:The minCompileSdk (31) specified in a compileSdkVersion (android-30).
最近升级了Flutter到2.10版本,发现无法编译,错误如下,然后安装了Android SDK31也依然无法解决,通过研究网络上的方案,解决如下:
1,升级Gradle到7.4.2,在VScode终端运行gradle init重建gradle环境(因为项目在升级前建立,gradle版本是6.2),。
2,修改项目下面的Android目录下面的build.gradle 里面的 ext.kotlin_version = '1.6.20'到最新版本。
3,修改项目目录下面APP里面的build.gradle里面的 targetSdkVersion 31好像没有意义,30,31都没有问题。
4,没有修改flutter\packages\flutter_tools\gradle\flutter.gradle文件,因为里面已经是31版本了。
=========================================================
==========================================================
错误信息:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:checkReleaseAarMetadata'.
> Multiple task action failures occurred:
> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
> The minCompileSdk (31) specified in a
dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
is greater than this module's compileSdkVersion (android-30).
Dependency: androidx.window:window-java:1.0.0-beta04.
AAR metadata file: C:\Users\Administrator\.gradle\caches\transforms-2\files-2.1\625039eaad011f884ddd84f857a44b7f\jetified-window-java-1.0.0-beta04\META-INF\com\android\build\gradle\aar-metadata.properties.
> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
* 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 3s
Running Gradle task 'assembleRelease'... 4.1s
Gradle task assembleRelease failed with exit code 1
把kotlin的版本修改为最新版:1.6.20
https://kotlinlang.org/docs/gradle.html#plugin-and-versions
记录分享一下: