Android Studio运行项目报错::app:checkDebugAarMetadata执行失败
解决Android项目中
:app:checkDebugAarMetadata执行失败问题 问题重现
运行项目时出现以下错误:
Android Studio错误:Execution failed for task ':app:checkDebugAarMetadata'
检查AAR元数据发现两个核心冲突:
- 依赖项
androidx.core:core:1.12.0-alpha04要求应用必须针对Android API代号为"UpsideDownCake"的版本编译,当前app模块编译SDK为android-33。 - 依赖项
androidx.core:core-ktx:1.12.0-alpha04存在同样的编译版本要求冲突。
注:项目已显式声明androidx.core:core-ktx:1.10.0,但该预览版依赖由其他第三方库间接引入。
项目build.gradle配置如下:
plugins { id 'com.android.application' id 'org.jetbrains.kotlin.android' id 'com.onesignal.androidsdk.onesignal-gradle-plugin' //id 'com.google.gms.google-services' // Google Services plugin // Uncomment the plugin to use firebase and obtain the google-services.json file } android { compileSdk 33 defaultConfig { applicationId "com.softr.tiktokdownloader" minSdk 21 targetSdk 32 versionCode 1 versionName "2.0.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } dataBinding { enabled true } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } } compileOptions { sourceCompatibility JavaVersion.VERSION_11 targetCompatibility JavaVersion.VERSION_11 } kotlinOptions { jvmTarget = '11' } } dependencies { implementation fileTree(dir: "libs", include: ["*.jar"]) implementation project(path: ':jcplayer') implementation 'androidx.core:core-ktx:1.10.0' implementation 'androidx.appcompat:appcompat:1.6.1' implementation 'com.google.android.material:material:1.8.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' // required to avoid crash on Android 12 API 31 implementation 'androidx.work:work-runtime-ktx:2.8.1' // butterknife implementation 'com.jakewharton:butterknife:10.2.3' annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.3' /*admob*/ implementation 'com.google.android.gms:play-services-ads:19.8.0' /*admob open app ad*/ def lifecycle_version = "2.2.0" implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version" implementation "androidx.lifecycle:lifecycle-runtime:$lifecycle_version" annotationProcessor "androidx.lifecycle:lifecycle-compiler:$lifecycle_version" implementation 'com.airbnb.android:lottie:5.2.0' implementation 'com.infideap.drawerbehavior:drawer-behavior:1.0.4' implementation "androidx.cardview:cardview:1.0.0" implementation 'com.onesignal:OneSignal:[4.0.0, 4.99.99]' def multidex_version = "2.0.1" implementation "androidx.multidex:multidex:$multidex_version" implementation 'com.github.vimalcvs:Day-Night-Switch:1.0.3' implementation 'com.squareup.picasso:picasso:2.71828' implementation 'com.polyak:icon-switch:1.0.0' //payment def billing_version = "4.0.0" implementation "com.android.billingclient:billing:$billing_version" implementation 'com.github.chnouman:AwesomeDialog:1.0.5' implementation 'com.squareup.retrofit2:retrofit:2.9.0' implementation 'com.squareup.retrofit2:converter-gson:2.9.0' implementation 'com.squareup.okhttp3:logging-interceptor:4.9.1' implementation 'com.google.code.gson:gson:2.10' implementation 'com.github.bumptech.glide:glide:4.14.2' annotationProcessor 'com.github.bumptech.glide:compiler:4.14.1' implementation 'com.jackandphantom.android:circularimageview:1.2.0' implementation 'com.nabinbhandari.android:permissions:3.8' implementation 'com.github.esafirm:RxDownloader:1.0.1' implementation 'io.paperdb:paperdb:2.6' implementation 'com.github.HBiSoft:PickiT:0.1.10' implementation 'com.github.Andy671:Dachshund-Tab-Layout:v0.3.3' }
解决方案
方案一:强制统一core库版本(推荐)
在dependencies代码块末尾添加强制依赖策略,覆盖所有间接引入的预览版core库,保持使用指定的稳定版本:
configurations.all { resolutionStrategy { force 'androidx.core:core:1.10.0' force 'androidx.core:core-ktx:1.10.0' } }
修改后同步项目即可解决版本冲突,无需调整编译SDK版本。
方案二:升级至预览版SDK(仅用于测试新特性)
若需试用UpsideDownCake预览版API,修改android配置块:
android { compileSdkPreview "UpsideDownCake" defaultConfig { // 同步升级targetSdk至预览版 targetSdkPreview "UpsideDownCake" // ...其他原有配置 } // ...其他原有配置 }
注意:预览版SDK存在兼容性风险,不建议在正式生产项目中使用。
额外排查步骤
若需定位是哪个第三方库引入了预览版依赖,可执行以下命令查看完整依赖树:
- macOS/Linux:
./gradlew app:dependencies - Windows:
gradlew.bat app:dependencies
在输出结果中搜索androidx.core:core:1.12.0-alpha04即可找到依赖来源。
内容的提问来源于stack exchange,提问作者Yıldırım Beyazid
相关产品推荐
相关产品推荐

