xp-*_*vit 5 java android gradle android-gradle-plugin
我正在使用'com.android.tools.build:gradle:0.6.+'来构建我的android应用程序.
众所周知,Android dex不能包含相同库的不同版本.但是,当你想要使用Maven依赖时,如何处理情况需要一些你已经使用的库,但只是不同的版本.例.在build.gradle文件中有以下内容:
dependencies {
compile 'com.android.support:appcompat-v7:+'
compile 'com.github.chrisbanes.bitmapcache:library:2.3'
}
Run Code Online (Sandbox Code Playgroud)
产生错误:
UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.IllegalArgumentException: already added: Landroid/support/v4/app/FragmentManager$OnBackStackChangedListener;
at com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:123)
at com.android.dx.dex.file.DexFile.add(DexFile.java:163)...
Run Code Online (Sandbox Code Playgroud)
出现此错误的原因如下:http://search.maven.org/remotecontent? filepath = com/github/clinbanes/bitmapcache/library3.3 / library2.3.pom需要com.google.android:support-v4
com.android.support:appcompat-v7:+已经包含com.google.android:support-v4,这导致双重包含相同的类文件.
我现在正在寻找以下答案:使用Ant将所有依赖项下载到'libs'文件夹并使用编译文件('...')等.
更改包含顺序olso没有帮助.
我正在寻找强大而方便的解决方案.如何使用maven依赖关系,仍然没有上述异常?想法?成熟的android开发者如何管理这个?
Ser*_*kyi 11
您可以排除传递依赖项:
dependencies {
compile 'com.android.support:appcompat-v7:19.0.0'
compile ("com.github.chrisbanes.bitmapcache:library:2.3"){
exclude group: 'com.google.android', module: 'support-v4'
}
}
Run Code Online (Sandbox Code Playgroud)
它是开源库,因此您应该通知作者有关此问题或创建拉取请求.
| 归档时间: |
|
| 查看次数: |
4216 次 |
| 最近记录: |