在引入新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' } 编译运行 解决