I am trying to port an old IntelliJ project to use gradle. However, asselDebug does not work at the dx stage:
java.lang.IllegalArgumentException: already added: Lcom/google/inject/AbstractModule; at com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:123) at com.android.dx.dex.file.DexFile.add(DexFile.java:163) at com.android.dx.command.dexer.Main.processClass(Main.java:490) at com.android.dx.command.dexer.Main.processFileBytes(Main.java:459) at com.android.dx.command.dexer.Main.access$400(Main.java:67) at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:398) at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:245) at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:131) at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:109) at com.android.dx.command.dexer.Main.processOne(Main.java:422) at com.android.dx.command.dexer.Main.processAllFiles(Main.java:333) at com.android.dx.command.dexer.Main.run(Main.java:209) at com.android.dx.command.dexer.Main.main(Main.java:174) at com.android.dx.command.Main.main(Main.java:91)
My project is divided into two subprojects: the main project and the library project. Both of these projects have Roboguice and Guice as dependencies.
I tried Xav to offer a workaround to include a support library in several projects, as mentioned in this answer . A workaround is probably not even necessary, given that roboguice / guice come from the central center. I created a dummy library project, the only project that depends on roboguice / guice. I made my main project and the (true) library project depend on this dummy project. However, I get the same error.
How can this be fixed?
settings.gradle in the root directory:
include 'MainApp' include 'library' include 'common-library'
build.gradle in the root directory:
buildscript { repositories { mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:0.4.2' } } allprojects { version = '1.0' repositories { mavenCentral() } } apply plugin: 'android-reporting'
build.gradle in the main project and the real library project:
apply plugin: 'android' android { compileSdkVersion 15 buildToolsVersion "17.0" sourceSets { main { manifest.srcFile 'AndroidManifest.xml' java.srcDirs = ['src'] res.srcDirs = ['res'] } } } dependencies { compile project(':library') // only in main, not in real library compile project(':common-library') }
build.gradle in the dummy library project:
apply plugin: 'android-library' android { compileSdkVersion 15 buildToolsVersion "17.0" sourceSets { main { manifest.srcFile 'AndroidManifest.xml' java.srcDirs = ['src'] res.srcDirs = ['res'] } } } dependencies { compile 'org.roboguice:roboguice:2.0' compile 'com.google.inject:guice:3.0' }