任务:app:checkReleaseAarMetadata 失败反应本机

Task :app:checkReleaseAarMetadata FAILED react-native

我正在使用 ./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"

相关问题 -> here

最后,我通过将以下行添加到 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"
    }