Reputation: 426
I am trying to solve this exception. I have 2 android projects in intellij. Library and sample.
Library's deps are the following:
compile('com.inepex.simpleclient:SimpleClientImpl:0.9.4') {
exclude module: 'guice-assistedinject'
exclude module: 'guice'
exclude module: 'ormlite-core'
}
compile 'org.roboguice:roboguice:3.0.1@jar'
compile 'com.google.inject:guice:3.0:no_aop'
compile 'com.fasterxml.jackson.core:jackson-databind:2.4.0'
compile 'org.slf4j:slf4j-android:1.6.1-RC1@jar'
compile 'com.j256.ormlite:ormlite-android:4.45'
compile 'com.android.support:support-v4:19.1.0'
compile 'com.google.code.gson:gson:2.2.+'
sample app deps:
compile 'com.android.support:appcompat-v7:19.1.0'
compile 'com.android.support:gridlayout-v7:19.1.0'
compile project(':library')
gradle dependencies output for sample:
+--- com.android.support:appcompat-v7:19.1.0
| \--- com.android.support:support-v4:19.1.0
+--- com.android.support:gridlayout-v7:19.1.0
| \--- com.android.support:support-v4:19.1.0
\--- project :library
+--- com.inepex.simpleclient:SimpleClientImpl:0.9.4
| +--- com.j256.ormlite:ormlite-jdbc:4.45
| +--- io.netty:netty:3.5.7.Final
| \--- com.google.guava:guava:17.0
+--- org.roboguice:roboguice:3.0.1
+--- com.google.inject:guice:3.0
| +--- javax.inject:javax.inject:1
| +--- aopalliance:aopalliance:1.0
| \--- org.sonatype.sisu.inject:cglib:2.2.1-v20090111
| \--- asm:asm:3.1
+--- com.fasterxml.jackson.core:jackson-databind:2.4.0
| +--- com.fasterxml.jackson.core:jackson-annotations:2.4.0
| \--- com.fasterxml.jackson.core:jackson-core:2.4.0
+--- org.slf4j:slf4j-android:1.6.1-RC1
+--- com.j256.ormlite:ormlite-android:4.45
| \--- com.j256.ormlite:ormlite-core:4.45
+--- com.android.support:support-v4:19.1.0
\--- com.google.code.gson:gson:2.2.+ -> 2.2.4
Problem is that I can't find com.google.inject.Module more then once and the exception tells it is multiple defined. It is in guice.3.0-no_aop.jar.
Thanks in advance
Balint
Upvotes: 2
Views: 1313
Reputation: 17495
If your project uses multi dex configuration check the dex options in the gradle config. It should NOT contain incremental true
.
I had a project failing to execute instrumentation tests from Android Studio with this error after each code change. I had to clean the project before each run until I removed this property.
(this property defaults to false so if it's not there you're fine)
dexOptions {
incremental false
javaMaxHeapSize '4g'
}
For more details on what this dex option does check What does the "Incremental Dex" option in Android Studio do?
With gradle you can create a dependency tree. This tree will mark obvious duplicates with an asterix at the end. Example:
./gradlew dependencies Application:dependencies
Example output (from the Instrumentation sample project, incomplete though)
_debugApk - ## Internal use, do not manually configure ##
\--- com.android.support:support-v4:21.0.2
\--- com.android.support:support-annotations:21.0.2
_debugCompile - ## Internal use, do not manually configure ##
\--- com.android.support:support-v4:21.0.2
\--- com.android.support:support-annotations:21.0.2
_releaseApk - ## Internal use, do not manually configure ##
\--- com.android.support:support-v4:21.0.2
\--- com.android.support:support-annotations:21.0.2
_releaseCompile - ## Internal use, do not manually configure ##
\--- com.android.support:support-v4:21.0.2
\--- com.android.support:support-annotations:21.0.2
androidJacocoAgent - The Jacoco agent to use to get coverage data.
\--- org.jacoco:org.jacoco.agent:0.7.1.201405082137
androidJacocoAnt - The Jacoco ant tasks to use to get execute Gradle tasks.
\--- org.jacoco:org.jacoco.ant:0.7.1.201405082137
+--- org.jacoco:org.jacoco.core:0.7.1.201405082137
| \--- org.ow2.asm:asm-debug-all:5.0.1
+--- org.jacoco:org.jacoco.report:0.7.1.201405082137
| +--- org.jacoco:org.jacoco.core:0.7.1.201405082137 (*)
| \--- org.ow2.asm:asm-debug-all:5.0.1
\--- org.jacoco:org.jacoco.agent:0.7.1.201405082137
Note how the org.jacoco.core dependency is listed here twice and marked with the (*).
Upvotes: 2