Reputation: 1927
How do I get my code to use only one class from one JAR file when the same class from two JAR files exist in the files ormlite-android-4.6.jar & ormlite-core-4.45.jar without running into this error?
Here is a copy of my build.gradle file:
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')
}
Here is the error I get:
:app:packageAllDebugClassesForMultiDex FAILED
FAILURE: Build failed with an exception.
What went wrong: Execution failed for task ':app:packageAllDebugClassesForMultiDex'.
java.util.zip.ZipException: duplicate entry: com/j256/ormlite/dao/BaseDaoImpl$1.class
Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 5.131 secs
The code I think is trying to use BaseDaoImpl.class which both exists in package com.j256.ormlite.dao.BaseDaoImpl in both ormlite-android-4.6.jar & ormlite-core-4.45.jar. How do I get it to use one class from one JAR file without running into this error?
Upvotes: 2
Views: 3083
Reputation: 4971
You can use
compile ("net.danlew:android.joda:2.9.0") {
exclude group: 'org.joda.time'
}
or to exclude module use
compile ("net.danlew:android.joda:2.9.0") {
exclude module: 'jode-time'
}
Upvotes: 3
Reputation: 3451
Run "gradlew dependencies" which will allow you to see all the libraries. You can use the "exclude" directive to remove duplicate libraries.
Look here to read more about the exclude directive: https://gradle.org/docs/current/userguide/dependency_management.html#sub:exclude_transitive_dependencies
Upvotes: 0