我正在使用./gradlew assembleRelease
命令为我的项目制作一个发布版本,但它给了我这个错误。
> Task :app:checkReleaseAarMetadata FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:checkReleaseAarMetadata'.
> 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.core:core:1.7.0-alpha02.
AAR metadata file: /Users/classic/.gradle/caches/transforms-2/files-2.1/64ba04558e5775ef86bc1e2e88b04a01/core-1.7.0-alpha02/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.
我不能编辑我的build.gradle
来修复这个错误,因为项目有一些依赖关系在改变compileSdkVersion
后破裂。
编辑
我将以下行添加到我的android/app/build.gradle
,但这对我不起作用。
implementation "androidx.core:core-ktx:1.6.0"
相关问题->
最后,我通过将以下行添加到android/build.gradle
来修复此错误。
buildscript {
ext {
androidXCore = "1.6.0" // <-- Add this line
buildToolsVersion = "29.0.3"
minSdkVersion = 21
compileSdkVersion = 30
targetSdkVersion = 29
ndkVersion = "20.1.5948944"
}
我使用旧的RN,所以我升级了,然后它为我工作。我做了以下改变。Gradle clean,运行应用
package.json
"react-native": "0.67.4", // previous 0.62.3
"react-native-reanimated": "^2.8.0", // previous "1.13.0",
android gradle-wrapper gradle 包装器。属性//前6.1.1
distributionUrl=https://services.gradle.org/distributions/gradle-7.2-all.zip
android build.gradle
buildscript {
ext {
buildToolsVersion = "30.0.2" // previous "29.0.2"
minSdkVersion = 23
compileSdkVersion = 30 // 29 previous
targetSdkVersion = 30 // previous 29
}
...
}
dependencies {
classpath('com.android.tools.build:gradle:4.2.2')
___
}
allprojects {
repositories {
exclusiveContent {
filter {
includeGroup "com.facebook.react"
}
forRepository {
maven {
url "$rootDir/../node_modules/react-native/android"
}
}
}
. . .
}
}