You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何排查间接依赖的Play Core库并适配Android 14?

解决Google Play Core 1.10.3不兼容Android 14的问题

一、找出引入Play Core的依赖库

你未直接声明Play Core依赖,但它是某个第三方库的间接依赖,可通过以下Gradle命令快速定位:

  1. 查看完整依赖树:
    在项目根目录执行对应命令:

    # macOS/Linux
    ./gradlew app:dependencies
    # Windows
    gradlew.bat app:dependencies
    

    在输出结果中搜索com.google.android.play:core,即可看到它被哪个依赖库引入(常见来源包括Firebase系列、Google Play Services系列库)。

  2. 直接定位依赖来源:
    使用精准命令直接输出Play Core的依赖路径:

    # macOS/Linux
    ./gradlew app:dependencyInsight --dependency com.google.android.play:core
    # Windows
    gradlew.bat app:dependencyInsight --dependency com.google.android.play:core
    

二、解决不兼容问题

找到引入旧版Play Core的依赖后,可通过两种方式修复:

  • 更新父依赖:将引入旧版Play Core的第三方库升级到最新稳定版,新版本通常会内置兼容Android 14的Play Core。比如你项目中的Firebase、Google Play Services系列库,均可升级至官方最新版本。
  • 强制替换Play Core版本:若暂时无法更新父依赖,可在模块级build.gradle中添加版本强制替换策略,直接指定兼容Android 14的Play Core版本:
    configurations.all {
        resolutionStrategy {
            force 'com.google.android.play:core:1.12.0' // 替换为最新兼容版本
        }
    }
    
    同时确保项目targetSdkVersion已设置为34,满足Google Play的适配要求。

三、验证修复

再次执行./gradlew app:dependencyInsight --dependency com.google.android.play:core检查,确认Play Core版本已更新至兼容Android 14的版本即可。

内容的提问来源于stack exchange,提问作者alexC

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.21 06:12:07