gpt4 book ai didi

Android 应用无法构建——在依赖项的 androidx.work :work-runtime:2. 7.0-beta01 中指定的 minCompileSdk (31)

转载 作者:行者123 更新时间:2023-12-04 23:35:48 24 4
gpt4 key购买 nike

我正在尝试在我的 M1 中构建一个项目,
但是当我运行 npx react-native run-android 时出现此错误

FAILURE: Build 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
> 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.work:work-runtime:2.7.0-beta01.
AAR metadata file: /Users/macpro/.gradle/caches/transforms-3/999e9d813832e06d8f1b7de52647a502/transformed/work-runtime-2.7.0-beta01/META-INF/com/android/build/gradle/aar-metadata.properties.
安卓/build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext {
buildToolsVersion = "30.0.0"
minSdkVersion = 21
compileSdkVersion = 30
targetSdkVersion = 30
supportLibVersion = "28.0.0"
}
repositories {
google()
jcenter()
}
dependencies {
classpath('com.android.tools.build:gradle:4.1.2')
classpath('com.google.gms:google-services:4.3.0')
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

allprojects {
repositories {
mavenLocal()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url("$rootDir/../node_modules/react-native/android")
}
maven {
// Android JSC is installed from npm
url("$rootDir/../node_modules/jsc-android/dist")
}

google()
jcenter()
maven { url 'https://www.jitpack.io' }
}

}
gradle-wrapper.properties
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.9-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

最佳答案

导致错误是因为您的依赖项之一在内部使用 WorkManager 2.7.0-beta01今天发布的(需要 API 31)。就我而言,它是 CheckAarMetadata.kt .
您可以通过强制 Gradle 对适用于 API 30 的传递依赖项使用旧版本的 Work Manager 来修复它。在您的 build.gradle 中文件添加:

dependencies {
def work_version = "2.6.0"
// Force WorkManager 2.6.0 for transitive dependency
implementation("androidx.work:work-runtime-ktx:$work_version") {
force = true
}
}
这应该解决它。

关于Android 应用无法构建——在依赖项的 androidx.work :work-runtime:2. 7.0-beta01 中指定的 minCompileSdk (31),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69037481/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com