如何解决依赖androidx.core:core:1.15.0-alpha01导致的:app执行失败问题?
解决Android项目构建失败:AAR元数据检查错误与SDK依赖问题
问题概述
构建项目时触发以下错误:
Execution failed for task ':app:checkDebugAarMetadata'.
A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
An issue was found when checking AAR metadata:1. Dependency 'androidx.core:core:1.15.0-alpha01' requires libraries and applications that depend on it to compile against version 35 or later of the Android APIs. :app is currently compiled against android-34. Also, the maximum recommended compile SDK version for Android Gradle plugin 8.1.1 is 34. Recommended action: Update this project's version of the Android Gradle plugin to one that supports 35, then update this project to use compileSdk of at least 35. Note that updating a library or application's compileSdk (which allows newer APIs to be used) can be done separately from updating targetSdk (which opts the app in to new runtime behavior) and minSdk (which determines which devices the app can be installed on).
尝试将compileSdkVersion改为35后,出现新错误:
Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
Could not determine the dependencies of null.
Failed to find Platform SDK with path: platforms;android-35
手动添加implementation('androidx.core:core:1.13.1')强制指定旧版本,问题未解决。
补充SDK信息:
- SDK Tools:

- SDK Platforms:

解决方案
方案1:强制锁定androidx.core依赖版本(无需升级SDK/AGP)
单纯添加implementation无法覆盖传递依赖,需在app/build.gradle中配置依赖解析策略,强制所有模块使用指定版本:
android { // 其他配置... configurations.all { resolutionStrategy { force 'androidx.core:core:1.13.1' // 若有core的其他衍生依赖,也需一并锁定,比如: // force 'androidx.core:core-ktx:1.13.1' } } }
同步gradle后重新构建。
方案2:升级SDK与AGP以适配compileSdk 35
如果需要使用高版本依赖,按以下步骤操作:
- 安装Android 35 SDK平台
打开Android Studio的SDK Manager → 切换到SDK Platforms标签,勾选Android 15 (API 35),点击Apply完成安装。 - 升级Android Gradle Plugin(AGP)
AGP 8.1.1不支持compileSdk 35,需升级到支持的版本(比如8.2.0及以上):- 在项目根目录的
build.gradle或settings.gradle(AGP 7.0+)中修改AGP版本:plugins { id 'com.android.application' version '8.2.2' apply false // 其他插件... }
- 在项目根目录的
- 更新compileSdkVersion
在app/build.gradle中修改:android { compileSdkVersion 35 // 可选:targetSdkVersion也可同步升级到35 targetSdkVersion 35 // 其他配置... } - 同步gradle并重新构建项目。
内容的提问来源于stack exchange,提问作者Marcos Rezende
相关产品推荐
相关产品推荐

