我的项目取决于依赖项A和依赖项B。
依赖项A也依赖于依赖项B,但它的版本不同。
问题出在项目A的build.gradle
依赖项B中,直接使用file和fileTree方法将其作为jar包含在内:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile files('libs/B.jar')
}
我的项目build.gradle
如下所示:
dependencies {
compile 'com.B:B:myvesion'
compile('com.A:A:theirversion') {
exclude module: 'B'
}
}
但是我的构建因以下异常而失败:
Execution failed for task ':myproject:transformDexArchiveWithDexMergerForDebug'.
> com.android.build.api.transform.TransformException: com.android.dex.DexException: Multiple dex files define Lcom/B/someclass;
我想jar
从项目中排除B版本并使用我的版本。我该怎么做呢?看来该exclude
指令在我的情况下不起作用。
对于jar文件,您不能这样做。
您可以排除传递依赖项(在pom文件中描述)。jar文件不是传递依赖项。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句