[英]Build failed because of min SDK version on flutter
I have ran flutter upgrade
on my app and now when I try to run flutter run
I get this error doing the gradle build phase.我已经在我的应用程序上运行了flutter upgrade
,现在当我尝试运行flutter run
时,我在执行 gradle 构建阶段时收到此错误。
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\jp_ku\.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
> 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\jp_ku\.gradle\caches\transforms-2\files-2.1\a78fdf90e4c1f8464b19895cfb365f3f\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 13s
Exception: Gradle task assembleDebug failed with exit code 1
This are my dependencies on pubspec.yaml
:这是我对pubspec.yaml
的依赖:
version: 2.1.0
environment:
sdk: ">=2.12.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.2
intl: ^0.17.0
sqflite: ^2.0.0+3
provider: ^5.0.0
linked_scroll_controller: ^0.2.0
flutter_neumorphic: ^3.1.0
dev_dependencies:
flutter_test:
sdk: flutter
flutter_launcher_icons: "^0.9.1"
flutter_icons:
android: "launcher_icon"
ios: false
image_path: "assets/icon/icon.png"
How can I fix this issue?我该如何解决这个问题? I've tried changing the compileSdkVersion on gradle but then it just gives me another error:我已经尝试更改 gradle 上的 compileSdkVersion 但它只是给了我另一个错误:
C:/Users/jp_ku/.gradle/caches/transforms-2/files-2.1/cdd51607f1d98bcc689bce197d763afe/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.```
You need to update your minimum SDK in ./android/app/build.gradle
Example:您需要在 ./android/app/build.gradle 中更新您的最低./android/app/build.gradle
示例:
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.projectname"
minSdkVersion 31 //*** This is the part that needs to be changed, previously was 30
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
Reference: How to change Android minSdkVersion in flutter project参考: 如何在 flutter 项目中更改 Android minSdkVersion
You need to change kotlin version in ./android/build.gradle
您需要在./android/build.gradle
中更改 kotlin 版本
Example:例子:
buildscript {
ext.kotlin_version = '1.5.1' //change 1.5.1 to 1.1.15
You need to update following lines in./android/app/build.gradle Example:您需要在 ./android/app/build.gradle 示例中更新以下行:
android {
compileSdkVersion flutter.compileSdkVersion <--update this>
...
defaultConfig {
minSdkVersion flutter.minSdkVersion <-- this>
targetSdkVersion flutter.targetSdkVersion <-- this>
}
}
some of your flutter packages may give errors so update them to latest version or ask the package provider to release latest version accordingly您的一些 flutter 软件包可能会出错,因此请将它们更新到最新版本或要求 package 提供商相应地发布最新版本
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.