Android Studio 构建问题:任务:app:checkDebugAarMetadata 失败

Android Studio build problem: Task :app:checkDebugAarMetadata FAILED

我刚刚创建了一个新的 Android Studio 项目,放置了两个按钮并想要 运行 该应用程序。但它并没有像上次那样成功并抛出了这些错误信息:

´´´ 失败:构建失败,出现异常。

A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction One or more issues found when checking AAR metadata values:

 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.appcompat:appcompat:1.4.0.
 AAR metadata file: C:\Users\elias\.gradle\caches\transforms-3c44282e022cd3a9cbc870646694ab0a\transformed\appcompat-1.4.0\META-INF\com\android\build\gradle\aar-metadata.properties.
 
 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.appcompat:appcompat-resources:1.4.0.
 AAR metadata file: C:\Users\elias\.gradle\caches\transforms-3cb3fa1e8cc28bcefb0e641636adeb7\transformed\jetified-appcompat-resources-1.4.0\META-INF\com\android\build\gradle\aar-metadata.properties.
 
 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.emoji2:emoji2-views-helper:1.0.0.
 AAR metadata file: C:\Users\elias\.gradle\caches\transforms-3f816c6396ec05574f231a43fe2fe51\transformed\jetified-emoji2-views-helper-1.0.0\META-INF\com\android\build\gradle\aar-metadata.properties.
 
 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.emoji2:emoji2:1.0.0.
 AAR metadata file: C:\Users\elias\.gradle\caches\transforms-3\f3f3fbf95d792df4fdb767de361ba6d6\transformed\jetified-emoji2-1.0.0\META-INF\com\android\build\gradle\aar-metadata.properties.
 
 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.
 AAR metadata file: C:\Users\elias\.gradle\caches\transforms-3786a0692ca429b2403ede1513a9cc7\transformed\core-1.7.0\META-INF\com\android\build\gradle\aar-metadata.properties.
 
 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.lifecycle:lifecycle-process:2.4.0.
 AAR metadata file: C:\Users\elias\.gradle\caches\transforms-304eafb35ec41197ba4898ae753e255\transformed\jetified-lifecycle-process-2.4.0\META-INF\com\android\build\gradle\aar-metadata.properties.
 
 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.lifecycle:lifecycle-runtime:2.4.0.
 AAR metadata file: C:\Users\elias\.gradle\caches\transforms-3\c726bc0560b0638acbd3117252a1943f\transformed\lifecycle-runtime-2.4.0\META-INF\com\android\build\gradle\aar-metadata.properties.

此版本中使用了已弃用的 Gradle 功能,使其与 Gradle 8.0 不兼容。 使用“--warning-mode all”来显示各个弃用警告。 参见 https://docs.gradle.org/7.0.2/userguide/command_line_interface.html#sec:command_line_warnings

25 秒内构建失败 22 项可操作任务:22 项已执行

由于配置问题,构建扫描未发布。

尚未同意 Gradle 服务条款。

更多信息,请参阅https://gradle.com/help/plugin-terms-of-service

或者,如果您使用的是 Gradle Enterprise,请指定服务器位置。 有关详细信息,请参阅 https://gradle.com/help/plugin-enterprise-config。 ´´´

我也卸载了 Android Studio,但是没用。有谁知道该怎么办?我是 Android Studio 和 Gradle 的新手。谢谢!

minCompileSdk 为31,但minSdkVersion 明显较低。增加项目的compileSdk就可以解决问题。

android {
    compileSdk 31
...
}