Flutter 包:清单合并失败:uses-sdk:minSdkVersion XX 不能小于库中声明的版本 XX

问题描述 投票:0回答:1

我无法构建 android apk 尽管使用了最新的 Targetsdk 和 minsdk 设置,但我在 Flutter 项目上收到了以下错误 有什么解决方法吗?

我的颤振版本:

[✓] Flutter(频道稳定,3.24.3,在 macOS 14.6.1 23G93 darwin-arm64 上,区域设置 en-DZ) [✓] Android 工具链 - 为 Android 设备开发(Android SDK 版本 35.0.0) • Java 版本 OpenJDK 运行时环境(构建 17.0.11+0-17.0.11b1207.24-11852314)

我的JDK: Java(TM) SE 运行时环境(版本 22.0.2+9-70) Java HotSpot(TM) 64 位服务器虚拟机(版本 22.0.2+9-70,混合模式,共享)

设置.gradle

plugins {
    id "dev.flutter.flutter-plugin-loader" version "1.0.0"
    id "com.android.application" version "8.6.0" apply false
    id "org.jetbrains.kotlin.android" version "2.0.20" apply false
    id "com.google.gms.google-services" version "4.4.2" apply false
    id("com.google.firebase.crashlytics") version "3.0.2" apply false

}

gradle-wrapper.properties

distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.1-all.zip

gradle.属性

org.gradle.jvmargs=-Xmx2048m -XX:MaxMetaspaceSize=512m

应用程序/build.gradle

   android {
    ndkVersion "27.1.12297006"
    compileSdkVersion 35
    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }
    defaultConfig {
        applicationId "xx.xxx.xx"
        minSdkVersion 24
        targetSdkVersion 35
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        multiDexEnabled true
        ndk {
            debugSymbolLevel 'SYMBOL_TABLE'
        }
    }

    signingConfigs {
        release {
            keyAlias keystoreProperties['keyAlias']
            keyPassword keystoreProperties['keyPassword']
            storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
            storePassword keystoreProperties['storePassword']
        }
    }

    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile(
                    'proguard-android-optimize.txt'),
                    'proguard-rules.pro'

            firebaseCrashlytics {
                nativeSymbolUploadEnabled true
                unstrippedNativeLibsDir 'build/intermediates/merged_native_libs/release/out/lib'

            }

            ndk {
                // replace with 'FULL' if you need more info,
                // but note that it will increase the file size of your appbundle dramatically.
                debugSymbolLevel 'SYMBOL_TABLE'
            }

            signingConfig signingConfigs.release
        }
    }
    namespace 'xx.xxx.xx'

}

pubspec.yaml

version: 1.3.3+80
environment:
  sdk: ">=2.17.0 <3.0.0"
dependencies:
  flutter:
    sdk: flutter
  flutter_localizations:
    sdk: flutter
    
  cupertino_icons: 1.0.8
  firebase_core: 3.4.1
  firebase_messaging: 15.1.1
  shared_preferences: 2.3.2

  intl: 0.19.0
  bloc: 8.1.4
  url_launcher: 6.3.0
  flutter_bloc: 8.1.6
  share_plus: 10.0.2
  dio: 5.7.0
  cached_network_image: 3.4.1
  card_swiper: 3.0.1
  shimmer: 3.0.0
  image_picker: 1.1.2
  photo_view: 0.15.0

  google_maps_flutter: 2.9.0
  intro_views_flutter: 3.2.0
  rxdart: 0.28.0
  font_awesome_flutter: 10.7.0
  flutter_rating_bar: 4.0.1
  qr_flutter: 4.1.0
  dotted_border: 2.1.0
  animations: 2.0.11

  flutter_svprogresshud: 1.0.1

  #flutter_svprogresshud:
   # git:
    #  url: https://github.com/Syaba999/flutter_svprogresshud

  webview_flutter: 4.9.0
  showcaseview: 3.0.0
  google_mobile_ads: 5.1.0

  video_player: 2.9.1
  path_provider: 2.1.4

  open_filex: 4.5.0
  geolocator: 13.0.1
  shared_value: ^3.0.0
  one_context: ^4.0.0
  toast: ^0.3.0
  flutter_widget_from_html: 0.15.2
  screen_protector: ^1.4.2

  flutter_feather_icons: ^2.0.0+1
  get: ^4.6.6

  connectivity_plus: 6.0.5

  new_version_plus: ^0.0.11
  rate_my_app: ^2.2.0

  flutter_easyloading: ^3.0.5
  upgrader: ^11.0.0
  #  sentry_flutter: ^7.16.1

  firebase_crashlytics: ^4.1.1
  firebase_performance: ^0.10.0+6
  firebase_app_check: ^0.3.1+1
  #ios
  firebase_analytics: ^11.3.1

  flutter_map: ^7.0.2
  latlong2: ^0.9.1

  qr_code_scanner: 1.0.1

  #qr_code_scanner:
   # git:
    #  url: https://github.com/samnbd/qr_code_scanner
     # ref: master
      #version: ^1.0.0

  #qr_code_scanner:
   # git:
    #  url: https://github.com/dola99/qr_code_scanner
     # ref: update

  syncfusion_flutter_pdfviewer: ^26.2.8
  in_app_review: 2.0.9

  flutter_colorpicker: 1.1.0
  shorebird_code_push: ^1.1.4
  restart_app: ^1.3.2

  assistive_touch: 0.2.0
  pin_code_fields: 8.0.1

  location: ^7.0.0

  device_info_plus: 10.1.2

dependency_overrides:
  package_info_plus: 8.0.2
  # http: ^1.2.2
  web: ^1.0.0

错误日志:

    1: Task failed with an exception.
-----------
* What went wrong:
Unable to make progress running work. There are items queued for execution but none of them can be started

2: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':open_filex:processDebugAndroidTestManifest'.
> Manifest merger failed : uses-sdk:minSdkVersion 16 cannot be smaller than version 19 declared in library [androidx.fragment:fragment:1.7.1] /Users/g-besoin/.gradle/caches/8.10.1/transforms/6794493f0b6fdfd574744e6342ad8026/transformed/fragment-1.7.1/AndroidManifest.xml as the library might be using APIs not available in 16
    Suggestion: use a compatible library with a minSdk of at most 16,
        or increase this project's minSdk version to at least 19,
        or use tools:overrideLibrary="androidx.fragment" to force usage (may lead to runtime failures)

3: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':geolocator_android:processDebugAndroidTestManifest'.
> Manifest merger failed : uses-sdk:minSdkVersion 16 cannot be smaller than version 19 declared in library [com.google.android.gms:play-services-location:21.2.0] /Users/g-besoin/.gradle/caches/8.10.1/transforms/9f900b64ef0ab40207bfa7eabcd4c437/transformed/jetified-play-services-location-21.2.0/AndroidManifest.xml as the library might be using APIs not available in 16
    Suggestion: use a compatible library with a minSdk of at most 16,
        or increase this project's minSdk version to at least 19,
        or use tools:overrideLibrary="com.google.android.gms.location" to force usage (may lead to runtime failures)

4: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':flutter_svprogresshud:checkDebugAndroidTestAarMetadata'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
   > 20 issues were found when checking AAR metadata:
     
       1.  Dependency 'androidx.fragment:fragment:1.7.1' requires libraries and applications that
           depend on it to compile against version 34 or later of the
           Android APIs.
     
           :flutter_svprogresshud is currently compiled against android-28.
     
           Recommended action: Update this project to use a newer compileSdk
           of at least 34, for example 35.
     
           Note that updating a library or application's compileSdk (which
           allows newer APIs to be used) can be done separately from updating
           targetSdk (which opts the app in to new runtime behavior) and
           minSdk (which determines which devices the app can be installed
           on).
     
       2.  Dependency 'androidx.window:window:1.2.0' requires libraries and applications that
           depend on it to compile against version 34 or later of the
           Android APIs.
     
           :flutter_svprogresshud is currently compiled against android-28.
     
           Recommended action: Update this project to use a newer compileSdk
           of at least 34, for example 35.
     
           Note that updating a library or application's compileSdk (which
           allows newer APIs to be used) can be done separately from updating
           targetSdk (which opts the app in to new runtime behavior) and
           minSdk (which determines which devices the app can be installed
           on).
     
       3.  Dependency 'androidx.window:window-java:1.2.0' requires libraries and applications that
           depend on it to compile against version 34 or later of the
           Android APIs.
     
           :flutter_svprogresshud is currently compiled against android-28.
     
           Recommended action: Update this project to use a newer compileSdk
           of at least 34, for example 35.
     
           Note that updating a library or application's compileSdk (which
           allows newer APIs to be used) can be done separately from updating
           targetSdk (which opts the app in to new runtime behavior) and
           minSdk (which determines which devices the app can be installed
           on).
     
       4.  Dependency 'androidx.activity:activity:1.8.1' requires libraries and applications that
           depend on it to compile against version 34 or later of the
           Android APIs.
     
           :flutter_svprogresshud is currently compiled against android-28.
     
           Recommended action: Update this project to use a newer compileSdk
           of at least 34, for example 35.
     
           Note that updating a library or application's compileSdk (which
           allows newer APIs to be used) can be done separately from updating
           targetSdk (which opts the app in to new runtime behavior) and
           minSdk (which determines which devices the app can be installed
           on).
     
       5.  Dependency 'androidx.lifecycle:lifecycle-livedata-core-ktx:2.7.0' requires libraries and applications that
           depend on it to compile against version 34 or later of the
           Android APIs.
     
           :flutter_svprogresshud is currently compiled against android-28.
     
           Recommended action: Update this project to use a newer compileSdk
           of at least 34, for example 35.
     
           Note that updating a library or application's compileSdk (which
           allows newer APIs to be used) can be done separately from updating
           targetSdk (which opts the app in to new runtime behavior) and
           minSdk (which determines which devices the app can be installed
           on).
     
       6.  Dependency 'androidx.lifecycle:lifecycle-livedata:2.7.0' requires libraries and applications that
           depend on it to compile against version 34 or later of the
           Android APIs.
     
           :flutter_svprogresshud is currently compiled against android-28.
     
           Recommended action: Update this project to use a newer compileSdk
           of at least 34, for example 35.
     
           Note that updating a library or application's compileSdk (which
           allows newer APIs to be used) can be done separately from updating
           targetSdk (which opts the app in to new runtime behavior) and
           minSdk (which determines which devices the app can be installed
           on).
     
       7.  Dependency 'androidx.lifecycle:lifecycle-viewmodel:2.7.0' requires libraries and applications that
           depend on it to compile against version 34 or later of the
           Android APIs.
     
           :flutter_svprogresshud is currently compiled against android-28.
     
           Recommended action: Update this project to use a newer compileSdk
           of at least 34, for example 35.
     
           Note that updating a library or application's compileSdk (which
           allows newer APIs to be used) can be done separately from updating
           targetSdk (which opts the app in to new runtime behavior) and
           minSdk (which determines which devices the app can be installed
           on).
     
       8.  Dependency 'androidx.lifecycle:lifecycle-livedata-core:2.7.0' requires libraries and applications that
           depend on it to compile against version 34 or later of the
           Android APIs.
     
           :flutter_svprogresshud is currently compiled against android-28.
     
           Recommended action: Update this project to use a newer compileSdk
           of at least 34, for example 35.
     
           Note that updating a library or application's compileSdk (which
           allows newer APIs to be used) can be done separately from updating
           targetSdk (which opts the app in to new runtime behavior) and
           minSdk (which determines which devices the app can be installed
           on).
     
       9.  Dependency 'androidx.lifecycle:lifecycle-viewmodel-savedstate:2.7.0' requires libraries and applications that
           depend on it to compile against version 34 or later of the
           Android APIs.
     
           :flutter_svprogresshud is currently compiled against android-28.
     
           Recommended action: Update this project to use a newer compileSdk
           of at least 34, for example 35.
     
           Note that updating a library or application's compileSdk (which
           allows newer APIs to be used) can be done separately from updating
           targetSdk (which opts the app in to new runtime behavior) and
           minSdk (which determines which devices the app can be installed
           on).
     
      10.  Dependency 'androidx.core:core-ktx:1.13.1' requires libraries and applications that
           depend on it to compile against version 34 or later of the
           Android APIs.
     
           :flutter_svprogresshud is currently compiled against android-28.
     
           Recommended action: Update this project to use a newer compileSdk
           of at least 34, for example 35.
     
           Note that updating a library or application's compileSdk (which
           allows newer APIs to be used) can be done separately from updating
           targetSdk (which opts the app in to new runtime behavior) and
           minSdk (which determines which devices the app can be installed
           on).
     
      11.  Dependency 'androidx.core:core:1.13.1' requires libraries and applications that
           depend on it to compile against version 34 or later of the
           Android APIs.
     
           :flutter_svprogresshud is currently compiled against android-28.
     
           Recommended action: Update this project to use a newer compileSdk
           of at least 34, for example 35.
     
           Note that updating a library or application's compileSdk (which
           allows newer APIs to be used) can be done separately from updating
           targetSdk (which opts the app in to new runtime behavior) and
           minSdk (which determines which devices the app can be installed
           on).
     
      12.  Dependency 'androidx.lifecycle:lifecycle-runtime:2.7.0' requires libraries and applications that
           depend on it to compile against version 34 or later of the
           Android APIs.
     
           :flutter_svprogresshud is currently compiled against android-28.
     
           Recommended action: Update this project to use a newer compileSdk
           of at least 34, for example 35.
     
           Note that updating a library or application's compileSdk (which
           allows newer APIs to be used) can be done separately from updating
           targetSdk (which opts the app in to new runtime behavior) and
           minSdk (which determines which devices the app can be installed
           on).
     
      13.  Dependency 'androidx.lifecycle:lifecycle-process:2.7.0' requires libraries and applications that
           depend on it to compile against version 34 or later of the
           Android APIs.
     
           :flutter_svprogresshud is currently compiled against android-28.
     
           Recommended action: Update this project to use a newer compileSdk
           of at least 34, for example 35.
     
           Note that updating a library or application's compileSdk (which
           allows newer APIs to be used) can be done separately from updating
           targetSdk (which opts the app in to new runtime behavior) and
           minSdk (which determines which devices the app can be installed
           on).
     
      14.  Dependency 'androidx.savedstate:savedstate:1.2.1' requires libraries and applications that
           depend on it to compile against version 33 or later of the
           Android APIs.
     
           :flutter_svprogresshud is currently compiled against android-28.
     
           Recommended action: Update this project to use a newer compileSdk
           of at least 33, for example 35.
     
           Note that updating a library or application's compileSdk (which
           allows newer APIs to be used) can be done separately from updating
           targetSdk (which opts the app in to new runtime behavior) and
           minSdk (which determines which devices the app can be installed
           on).
     
      15.  Dependency 'androidx.profileinstaller:profileinstaller:1.3.1' requires libraries and applications that
           depend on it to compile against version 33 or later of the
           Android APIs.
     
           :flutter_svprogresshud is currently compiled against android-28.
     
           Recommended action: Update this project to use a newer compileSdk
           of at least 33, for example 35.
     
           Note that updating a library or application's compileSdk (which
           allows newer APIs to be used) can be done separately from updating
           targetSdk (which opts the app in to new runtime behavior) and
           minSdk (which determines which devices the app can be installed
           on).
     
      16.  Dependency 'androidx.startup:startup-runtime:1.1.1' requires libraries and applications that
           depend on it to compile against version 31 or later of the
           Android APIs.
     
           :flutter_svprogresshud is currently compiled against android-28.
     
           Recommended action: Update this project to use a newer compileSdk
           of at least 31, for example 35.
     
           Note that updating a library or application's compileSdk (which
           allows newer APIs to be used) can be done separately from updating
           targetSdk (which opts the app in to new runtime behavior) and
           minSdk (which determines which devices the app can be installed
           on).
     
      17.  Dependency 'androidx.tracing:tracing:1.2.0' requires libraries and applications that
           depend on it to compile against version 33 or later of the
           Android APIs.
     
           :flutter_svprogresshud is currently compiled against android-28.
     
           Recommended action: Update this project to use a newer compileSdk
           of at least 33, for example 35.
     
           Note that updating a library or application's compileSdk (which
           allows newer APIs to be used) can be done separately from updating
           targetSdk (which opts the app in to new runtime behavior) and
           minSdk (which determines which devices the app can be installed
           on).
     
      18.  Dependency 'androidx.arch.core:core-runtime:2.2.0' requires libraries and applications that
           depend on it to compile against version 33 or later of the
           Android APIs.
     
           :flutter_svprogresshud is currently compiled against android-28.
     
           Recommended action: Update this project to use a newer compileSdk
           of at least 33, for example 35.
     
           Note that updating a library or application's compileSdk (which
           allows newer APIs to be used) can be done separately from updating
           targetSdk (which opts the app in to new runtime behavior) and
           minSdk (which determines which devices the app can be installed
           on).
     
      19.  Dependency 'androidx.window.extensions.core:core:1.0.0' requires libraries and applications that
           depend on it to compile against version 33 or later of the
           Android APIs.
     
           :flutter_svprogresshud is currently compiled against android-28.
     
           Recommended action: Update this project to use a newer compileSdk
           of at least 33, for example 35.
     
           Note that updating a library or application's compileSdk (which
           allows newer APIs to be used) can be done separately from updating
           targetSdk (which opts the app in to new runtime behavior) and
           minSdk (which determines which devices the app can be installed
           on).
     
      20.  Dependency 'androidx.annotation:annotation-experimental:1.4.0' requires libraries and applications that
           depend on it to compile against version 34 or later of the
           Android APIs.
     
           :flutter_svprogresshud is currently compiled against android-28.
     
           Recommended action: Update this project to use a newer compileSdk
           of at least 34, for example 35.
     
           Note that updating a library or application's compileSdk (which
           allows newer APIs to be used) can be done separately from updating
           targetSdk (which opts the app in to new runtime behavior) and
           minSdk (which determines which devices the app can be installed
           on).


5: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':flutter_svprogresshud:processDebugAndroidTestManifest'.
> Manifest merger failed : uses-sdk:minSdkVersion 16 cannot be smaller than version 19 declared in library [androidx.fragment:fragment:1.7.1] /Users/g-besoin/.gradle/caches/8.10.1/transforms/6794493f0b6fdfd574744e6342ad8026/transformed/fragment-1.7.1/AndroidManifest.xml as the library might be using APIs not available in 16
    Suggestion: use a compatible library with a minSdk of at most 16,
        or increase this project's minSdk version to at least 19,
        or use tools:overrideLibrary="androidx.fragment" to force usage (may lead to runtime failures)


6: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':app:checkDebugAarMetadata'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
   > An issue was found when checking AAR metadata:
     
       1.  Dependency ':qr_code_scanner' requires core library desugaring to be enabled
           for :app.
     
           See https://developer.android.com/studio/write/java8-support.html for more
           details.

7: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':qr_code_scanner:compileDebugKotlin'.
> Inconsistent JVM-target compatibility detected for tasks 'compileDebugJavaWithJavac' (1.8) and 'compileDebugKotlin' (17).
android flutter gradle
1个回答
0
投票

我遇到了完全相同的问题。让我描述一下我是如何解决的。第一个建议操作是“更新此项目以使用至少 34 的较新的compileSdk,例如 35。”与您的应用程序无关,建议增加 google_mobile_ads 的compileSdk。

  1. 在应用程序的build.gradle中,恢复compileSdk和targetSdk,如下所示:

    compileSdk = flutter.compileSdkVersion targetSdk = flutter.targetSdkVersion

  2. 找到google_mobile_ads的build.gradle。它应该是“~/.pub-cache/hosted/pub.dev/google_mobile_ads-5.1.0/android/build.gradle”。将compileSdk更改为34,并在lintOptions中禁用“MissingClass”:

    安卓{ 编译SDK 34 ... lintOptions { ... 禁用“缺失类” } ... }

  3. 运行“./gradlew clean build”,构建应该会成功。

我还没有测试功能,只是解决了构建问题。让我知道它是否适合您。这是我的settings.gradle中的插件版本供您参考:

plugins {
    id "dev.flutter.flutter-plugin-loader" version "1.0.0"
    id "com.android.application" version '8.6.0' apply false
    id "org.jetbrains.kotlin.android" version "1.8.22" apply false
    id "com.google.gms.google-services" version "4.4.2" apply false
    id "com.google.firebase.crashlytics" version "3.0.2" apply false
}
© www.soinside.com 2019 - 2024. All rights reserved.