2022-03-08 依赖库中jar冲突

2022-03-08  本文已影响0人  颈椎以上瘫痪

当你的项目中依赖了多个动态库时,如果这些动态库中同时引用了某一个相同的库,但是版本又不同时,在编译时会出现类似如下错误:

found in modules gson-2.8.5.jar

错误的日志很明显,在控制台会出现较多的这种日志。比如这里笔者出现的错误就是多个依赖中同时依赖了gson库。

解决方案是App的build.gralde的dependencies节点中加上如下配置,排除所有库中相同的引用。


dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    //自定义Android开发库
    api 'com.gitee.premeditate:VenusAndroid:V1.0.22'

    implementation '...'

    configurations {
        all*.exclude group: 'com.google.code.gson'
    }
}
上一篇 下一篇

猜你喜欢

热点阅读