Android Studio error: "6 issues were found when checking AAR metadata"
回答 2
浏览 4668
2023-01-15
这是一个Gradle错误,我在运行空的"hello world"(从Empty Activity模板构建)而没有添加任何代码时得到的,以下是错误的内容。
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
> 6 issues were found when checking AAR metadata:
1. Dependency 'androidx.appcompat:appcompat-resources:1.6.0' requires libraries and applications that
depend on it to compile against version 33 or later of the
Android APIs.
:app is currently compiled against android-32.
Also, the maximum recommended compile SDK version for Android Gradle
plugin 7.2.0 is 32.
Recommended action: Update this project's version of the Android Gradle
plugin to one that supports 33, then update this project to use
compileSdkVerion of at least 33.
Note that updating a library or application's compileSdkVersion (which
allows newer APIs to be used) can be done separately from updating
targetSdkVersion (which opts the app in to new runtime behavior) and
minSdkVersion (which determines which devices the app can be installed
on).
2. Dependency 'androidx.appcompat:appcompat:1.6.0' requires libraries and applications that
depend on it to compile against version 33 or later of the
Android APIs.
:app is currently compiled against android-32.
Also, the maximum recommended compile SDK version for Android Gradle
plugin 7.2.0 is 32.
Recommended action: Update this project's version of the Android Gradle
plugin to one that supports 33, then update this project to use
compileSdkVerion of at least 33.
Note that updating a library or application's compileSdkVersion (which
allows newer APIs to be used) can be done separately from updating
targetSdkVersion (which opts the app in to new runtime behavior) and
minSdkVersion (which determines which devices the app can be installed
on).
我将在这两个错误信息之后停止,因为我怀疑修复一个错误信息就能修复所有六个错误信息。
下面是我的build.gradle (:app)
。
plugins {
id 'com.android.application'
}
android {
compileSdk 32
defaultConfig {
applicationId "com.enetapplications.empty"
minSdk 28
targetSdk 32
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.6.0'
implementation 'com.google.android.material:material:1.7.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
}
这个错误首先是在建立一个应用程序时发生的,当时我只处理了xml,并准备开始java--然后为了测试,我打开了一个空白的"空"项目,并收到了这个完全相同的错误,因此似乎与Android Studio的配置方式有关系。
2 个回答
#1楼
已采纳
得票数 7
将你的版本更新为33,如下所示
compileSdk 33
defaultConfig {
applicationId "com.enetapplications.empty"
minSdk 28
targetSdk 33
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
#2楼
得票数 4
进入你的build.gradle(:app)
,增加你的compileSdk和targetSdk.在那里写。
compileSdk 33
targetSdk 33
然后在顶部你会看到 "立即同步 "选项,点击它。现在你的问题已经解决了。