我正在查看位于Here的F-Droid上联系人合并应用程序的来源
并在编译期间获得UNEXPECTED TOP LEVEL EXCEPTION
。
我见过这样的问题,所以我知道错误来自重复的SPIClassIterator文件。在源代码中,创建了一个新的SPIClassIterator.java
,因此这是有道理的。我如何在gradle中使用exclude
删除原始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
的库。我很感激澄清。