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

Android Studio(Koala)引入库时如何排除指定组件?

解决Google Api Client Android依赖排除问题

你当前的exclude写法缺少明确的分组指定,Gradle 需要通过group参数定位要排除的依赖组件,另外代码里libs.googleApiClientAndroid后面的逗号是多余的,需要去掉。

下面是两种正确的写法:

方式一:排除整个org.apache.httpcomponents分组

implementation(libs.googleApiClientAndroid) {
    exclude(group = "org.apache.httpcomponents")
}

方式二:精准排除分组下的特定模块

如果只需要排除该分组下的某个具体模块(比如httpclient),可以加上module参数:

implementation(libs.googleApiClientAndroid) {
    exclude(group = "org.apache.httpcomponents", module = "httpclient")
}

如果还是无法生效,建议检查libs.versions.toml中该库的配置是否正确,确保依赖的group和name对应正确,示例配置如下:

[versions]
googleApiClientAndroid = "1.23.0" # 替换为你实际使用的版本

[libraries]
googleApiClientAndroid = { group = "com.google.android.gms", name = "play-services-auth-api-phone", version.ref = "googleApiClientAndroid" }

内容的提问来源于stack exchange,提问作者Joey Tatú

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.22 07:53:14