我正在尝试解决此异常。我在intellij有2个android项目。 图书馆和样本。
图书馆的代表如下:
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.+'
示例app deps:
compile 'com.android.support:appcompat-v7:19.1.0'
compile 'com.android.support:gridlayout-v7:19.1.0'
compile project(':library')
样本的gradle依赖项输出:
+--- 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
问题是我找不到com.google.inject.Module多一次,异常告诉它是多重定义的。它在guice.3.0-no_aop.jar中。
提前致谢
巴林特
答案 0 :(得分:2)
如果您的项目使用multi dex配置,请检查gradle配置中的dex选项。它不应包含incremental true
。
我有一个项目未能在每次代码更改后从Android Studio执行检测测试时出现此错误。我必须在每次运行之前清理项目,直到我删除了这个属性。
(此属性默认为false,所以如果它不在那里你就可以了)
dexOptions {
incremental false
javaMaxHeapSize '4g'
}
有关此dex选项检查What does the "Incremental Dex" option in Android Studio do?
的详细信息使用gradle,您可以创建依赖关系树。这棵树将在末尾用星号标记明显的重复。例如:
./gradlew dependencies Application:dependencies
示例输出(来自Instrumentation示例项目,虽然不完整)
_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
请注意org.jacoco.core依赖关系如何在此列出两次并标有(*)。