【发布时间】:2015-06-24 17:14:34
【问题描述】:
当文件 ormlite-android-4.6.jar 和 ormlite-core-4.45.jar 中存在两个 JAR 文件中的相同类时,如何让我的代码仅使用一个 JAR 文件中的一个类而不会遇到此错误?
这是我的 build.gradle 文件的副本:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.android.engineering"
minSdkVersion 16
targetSdkVersion 21
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
}
dependencies {
//compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.code.gson:gson:2.2.4'
compile 'joda-time:joda-time:2.0'
compile 'com.parse.bolts:bolts-android:1.+'
compile 'com.android.support:appcompat-v7:22.0.0'
compile files('libs/achartengine-1.1.0.jar')
compile files('libs/butterknife-5.1.2.jar')
compile files('libs/com.google.guava_1.6.0.jar')
compile files('libs/com.springsource.org.junit-4.10.0.jar')
compile files('libs/commons-collections-3.2.1.jar')
compile files('libs/dagger-1.1.0.jar')
compile files('libs/javax.inject-1.jar')
compile files('libs/opencsv-3.3.jar')
compile files('libs/ormlite-android-4.6.jar')
compile files('libs/ormlite-core-4.45.jar')
compile files('libs/log4j-1.2.16.jar')
compile files('libs/icepick-2.3.jar')
compile files('libs/mockito-core-1.9.5.jar')
}
这是我得到的错误:
:app:packageAllDebugClassesForMultiDex FAILED
FAILURE: Build failed with an exception.
-
出了什么问题: 任务 ':app:packageAllDebugClassesForMultiDex' 执行失败。
java.util.zip.ZipException:重复条目:com/j256/ormlite/dao/BaseDaoImpl$1.class
-
尝试: 使用 --stacktrace 选项运行以获取堆栈跟踪。使用 --info 或 --debug 选项运行以获得更多日志输出。
构建失败
总时间:5.131 秒
我认为代码正在尝试使用 BaseDaoImpl.class,它都存在于 ormlite-android-4.6.jar 和 ormlite-core-4.45.jar 包中的 com.j256.ormlite.dao.BaseDaoImpl 中。如何让它使用一个 JAR 文件中的一个类而不遇到此错误?
【问题讨论】:
标签: android jar android-studio build android-gradle-plugin