简体   繁体   English

由于 flutter 上的最小 SDK 版本,构建失败

[英]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.

相关问题 由于SDK导致flutter_oauth的版本解析失败 - Version solving failed for flutter_oauth because of SDK Android 中的构建目标和最小 SDK 版本 - Build Target and Min SDK version in Android &#39;flutter pub get&#39; 失败 - “因此,因为 fstore 依赖于 sdk 中的任何 flutter_test,版本解析失败。” - Failed 'flutter pub get' - "So, because fstore depends on flutter_test any from sdk, version solving failed." 您应该选择哪个构建目标和最低SDK版本? - What build target and min SDK version should you choose? Android 在 CI 中构建失败,因为 NDK 版本不兼容,但本地不兼容 - Android build failed in CI because of NDK version is not compatible, but not locally 构建失败错误:如果 (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) 找不到符号 - Build failed error: cannot find symbol if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) 随即忽略指定的Android SDK Build Tools版本 - The specified Android SDK Build Tools version is ignored in flutter Flutter 运行失败 [INSTALL_FAILED_OLDER_SDK] 需要更新的 sdk 版本 #31(当前版本为 #30) - Flutter Run Failure [INSTALL_FAILED_OLDER_SDK] Requires newer sdk version #31 (current version is #30) 适用于Android应用程序的Min SDK版本 - Min SDK version for android application 最低SDK版本Android-Cordova - Min sdk version android - Cordova
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM