在更新fullter后就报以下问题:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:checkDebugAarMetadata'.
> 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\liqiang\.gradle\caches\transforms-2\files-2.1\9f515ee58db509b5f4759e97c8eb6aa2\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
> 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:1.0.0-beta04.
AAR metadata file: C:\Users\liqiang\.gradle\caches\transforms-2\files-2.1\a909ff21160c236fa8213aba5c707997\jetified-window-1.0.0-beta04\META-INF\com\android\build\gradle\aar-metadata.properties.
* 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 4s
Exception: Gradle task assembleDebug failed with exit code 1
根据报错信息The minCompileSdk (31) specified 提示说需要最后sdk是31版本的,但是我们现在sdk版本是30的,大于这个版本所以需要修改以下配置,都修改成31的
android {
compileSdkVersion 31
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
/*configurations.all {
resolutionStrategy { force 'androidx.core:core-ktx:1.6.0' }
}*/
applicationId "cn.liginfo.kqjhq_app"
minSdkVersion 16
targetSdkVersion 31
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
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
}
}
}
修改之后,因为没有31版本的sdk,它会自动下载,但是下载后又出现以下报错信息
Flutter assets will be downloaded from https://storage.flutter-io.cn. Make sure you trust this source!
Launching lib\main.dart on sdk gphone x86 arm in debug mode...
Running Gradle task 'assembleDebug'...
e: C:/Users/liqiang/.gradle/caches/transforms-2/files-2.1/0dd39ff9faeeb501ffb52162e269003e/jetified-kotlin-stdlib-1.5.31.jar!/META-INF/kotlin-stdlib.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15.
e: C:/Users/liqiang/.gradle/caches/transforms-2/files-2.1/2ea246a87a592f122121cfd0846ffbea/jetified-kotlin-stdlib-jdk7-1.5.30.jar!/META-INF/kotlin-stdlib-jdk7.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15.
e: C:/Users/liqiang/.gradle/caches/transforms-2/files-2.1/9234cfcee40ec23fc2213363e9726513/jetified-window-1.0.0-beta04-api.jar!/META-INF/window_release.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15.
e: C:/Users/liqiang/.gradle/caches/transforms-2/files-2.1/9af1d6ff9000d18681a83cd875960957/jetified-kotlinx-coroutines-core-jvm-1.5.2.jar!/META-INF/kotlinx-coroutines-core.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15.
e: C:/Users/liqiang/.gradle/caches/transforms-2/files-2.1/b0b1eecff74e71ed1ef092403ad1018c/jetified-kotlin-stdlib-common-1.5.31.jar!/META-INF/kotlin-stdlib-common.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15.
e: C:/Users/liqiang/.gradle/caches/transforms-2/files-2.1/d91778f7878bf943ae593906c9fd7c75/jetified-kotlin-stdlib-jdk8-1.5.30.jar!/META-INF/kotlin-stdlib-jdk8.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15.
e: C:/Users/liqiang/.gradle/caches/transforms-2/files-2.1/df6880e9350e429186aa0973bbf49093/jetified-window-java-1.0.0-beta04-api.jar!/META-INF/window-java_release.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15.
e: C:/Users/liqiang/.gradle/caches/transforms-2/files-2.1/e484fc5cda5fe73d156ca3b50e47d38e/jetified-kotlinx-coroutines-android-1.5.2.jar!/META-INF/kotlinx-coroutines-android.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileDebugKotlin'.
> Compilation error. See log for more details
* 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 7s
┌─ Flutter Fix ────────────────────────────────────────────────────────────────────────────────┐
│ [!] Your project requires a newer version of the Kotlin Gradle plugin. │
│ Find the latest version on https://kotlinlang.org/docs/gradle.html#plugin-and-versions, then │
│ update D:\javadeveloping\Android\workspace\kqjhq_app\android\build.gradle: │
│ ext.kotlin_version = '<latest-version>' │
└──────────────────────────────────────────────────────────────────────────────────────────────┘
Exception: Gradle task assembleDebug failed with exit code 1
从报错信息中说是kotlin的版本不对,而且给出了具体的解决方案
Your project requires a newer version of the Kotlin Gradle plugin. │
│ Find the latest version on https://kotlinlang.org/docs/gradle.html#plugin-and-versions, then │
│ update D:\javadeveloping\Android\workspace\kqjhq_app\android\build.gradle: │
│ ext.kotlin_version = '<latest-version>'
你需要一个最新的kotlin gradle的插件,在https://kotlinlang.org/docs/gradle.html#plugin-and-versions查找最近的版本后,更新D:\javadeveloping\Android\workspace\kqjhq_app\android\build.gradle的文件,中ext.kotlin_version = ‘’ 的latest-version的值。
打开网页后我们发现最新的版本是1.6.10,而我们以前的是1.3.5:
只需改成1.6.10的版本就正常打包了