我正在查看位于HereUNEXPECTED TOP LEVEL EXCEPTION
的 F-Droid 上的联系人合并应用程序的来源,并在编译期间
获得了一个。
我见过这样的问题,所以我知道错误来自重复的 SPIClassIterator 文件。在源代码中,SPIClassIterator.java
创建了一个新的,所以这是有道理的。我该如何exclude
在 gradle 中使用来删除原始SPIClassIterator
类文件。或者避免这种情况的最佳方法是什么?
这是错误日志的截图。
:dexDebug
UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.IllegalArgumentException: already added:Lorg/apache/lucene/util/SPIClassIterator;
at com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:122)
at com.android.dx.dex.file.DexFile.add(DexFile.java:161)
at com.android.dx.command.dexer.Main.processClass(Main.java:685)
at com.android.dx.command.dexer.Main.processFileBytes(Main.java:634)
at com.android.dx.command.dexer.Main.access$600(Main.java:78)
at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:572)
at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284)
at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)
at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
at com.android.dx.command.dexer.Main.processOne(Main.java:596)
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:498)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:264)
at com.android.dx.command.dexer.Main.run(Main.java:230)
at com.android.dx.command.dexer.Main.main(Main.java:199)
at com.android.dx.command.Main.main(Main.java:103)
1 error; aborting
Error:Execution failed for task ':dexDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.7.0_75.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1
下面是 build.gradle 的一部分
dependencies {
compile 'com.tundem.aboutlibraries:library:2.0.3@aar'
compile 'com.android.support:support-v4:+'
compile 'org.ow2.asm:asm:4.0'
compile 'com.esotericsoftware.kryo:kryo:2.24.0'
compile ('org.apache.lucene:lucene-core:4.7.1'){
exclude module: 'SPIClassIterator'
}
compile 'org.apache.lucene:lucene-misc:4.7.1'
compile 'org.apache.lucene:lucene-queries:4.7.1'
compile 'org.apache.lucene:lucene-analyzers-common:4.7.1'
compile 'org.apache.lucene:lucene-codecs:4.7.1'
}
android {
compileSdkVersion 19
buildToolsVersion "19.1.0"
dexOptions {
preDexLibraries = false
}
packagingOptions {
pickFirst 'org/apache/lucene/util/SPIClassIterator.class'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/services/org.apache.lucene.codecs.Codec'
exclude 'META-INF/services/org.apache.lucene.codecs.PostingsFormat'
exclude 'META-INF/services/org.apache.lucene.codecs.DocValuesFormat'
}
我尝试使用排除,lucene-core
因为它是包含SPIClassIterator
我想排除的原始库的库。我很欣赏澄清。