bug记录 Android module依赖版本冲突解决

在引入新module后 报错 
 

Caused by: com.android.tools.r8.CompilationFailedException: Compilation failed to complete, origin:Applications\Gradle\caches\transforms-3\90d835a694fc2024d92761511c8aafd5\transformed\jetified-error_prone_annotations-2.38.0.jar:com/google/errorprone/annotations/Modifier.class

引入模块中可能包含了不同版本的 error_prone_annotations 库,导致了不兼容性。
我们需要检查项目的依赖树(可以通过运行 ./gradlew :app:dependencies 命令查看),确保没有重复或者版本冲突的依赖

命令行运行后发现确实有冲突依赖
 

+--- org.maplibre.gl:android-sdk:10.2.0
     |    +--- org.maplibre.gl:android-sdk-geojson:5.9.0
     |    |    \--- com.google.code.gson:gson:2.8.6 -> 2.13.1 (*)
     |    +--- com.mapbox.mapboxsdk:mapbox-android-gestures:0.7.0
     |    |    +--- androidx.core:core:1.0.0 -> 1.10.1 (*)
     |    |    \--- androidx.annotation:annotation:1.0.0 -> 1.6.0 (*)
     |    +--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.20 -> 1.9.10 (*)
     |    +--- org.maplibre.gl:android-sdk-turf:5.9.0
     |    |    \--- org.maplibre.gl:android-sdk-geojson:5.9.0 (*)
     |    +--- androidx.annotation:annotation:1.5.0 -> 1.6.0 (*)
     |    +--- androidx.fragment:fragment:1.5.5 (*)
     |    +--- com.squareup.okhttp3:okhttp:4.10.0 -> 4.12.0 (*)
     |    +--- com.jakewharton.timber:timber:5.0.1
     |    |    +--- org.jetbrains.kotlin:kotlin-stdlib:1.5.21 -> 1.9.10 (*)
     |    |    \--- org.jetbrains:annotations:20.1.0
     |    \--- androidx.interpolator:interpolator:1.0.0 (*)

但是如果将版本升级至module版本 或 使用app中依赖版本 都不可行
我们忽略就好
在app build中添加
 

implementation(project(':module')) {
    exclude group: 'com.orhanobut', module: 'logger'
    exclude group: 'com.squareup.okhttp3', module: 'okhttp'
    exclude group: 'com.google.code.gson', module: 'gson'
    exclude group: 'androidx.appcompat', module: 'appcompat'
}
编译运行 解决
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值