问题描述
我在项目中包含的库遇到了一些问题:一开始,这只是一个相互冲突的依赖问题,我通过排除来解决support-v4
是常用的共享模块.
I'm running into some trouble with a library I included into my project:
At the beginning it was just a conflicting dependencies issue that I resolved by excluding
support-v4
which is the commonly shared module.
问题在于,其中一个 lbsLib-release
似乎是在开发人员构建之前使用根项目内的普通 .jar
文件构建的.
The problem is that one of those lbsLib-release
seems to have been built with a plain .jar
file inside of the root project before the developer build.
通过运行 ./gradlew app:dependencies
我验证了构建图中没有引用依赖项.
By running ./gradlew app:dependencies
I verified that the dependency is not referenced in the build graph.
我发现这个 support-v4
嵌入到 classes.jar
中在:app/build/intermedites/exploded-aar/MyQaaAndroid/lbsLib-release/unspecified/classes.jar/
,如下图所示:
And I found this support-v4
embedded into the classes.jar
located
at : app/build/intermedites/exploded-aar/MyQaaAndroid/lbsLib-release/unspecified/classes.jar/
as you can see on the picture below:
我不能自己重建项目,因为它不是一个开源的lib,所以有两个问题:
I can't rebuild the project myself because it is not an open-sourced lib, so there is two problem:
如果我将
compile 'com.android.support:support-v4:18.0.+'
添加到build.gradle
一个multiple dex文件
在构建时抛出错误,因此库被引用了两次.
If I add
compile 'com.android.support:support-v4:18.0.+'
to thebuild.gradle
amultiple dex file
error is thrown at build time so the library is referenced twice.
`
如果我删除所有需要 support-v4
的库,它会在应用程序运行时引发缺少依赖项错误.
If I remove all libs which require support-v4
it throws a missing dependencies error at the application runtime.
所以我想知道是否可以从构建中排除这个 .jar
文件或使其他库依赖于 lbsLib-release
嵌入 support-v4
.jar
.
So I would like to know if it is possible to exclude this .jar
file from the build or to make the others libs depends on the lbsLib-release
embedded support-v4
.jar
.
推荐答案
尝试使用 resolutionStrategy
(API 参考) 在根 build.gradle
.
Try to use resolutionStrategy
(API reference) at root build.gradle
.
这篇关于Gradle 排除或添加硬包含在库 classes.jar 中的 JAR 文件的引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!