Reputation: 3305
I've set up a project with Dagger added to classpath, with all those M2E connectors, etc. In my pom.xml I have
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<dependencies>
<dependency>
<groupId>com.squareup.dagger</groupId>
<artifactId>dagger</artifactId>
<version>1.2.1</version>
</dependency>
<dependency>
<groupId>com.squareup.dagger</groupId>
<artifactId>dagger-compiler</artifactId>
<version>1.2.1</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.jakewharton</groupId>
<artifactId>butterknife</artifactId>
<version>5.1.0</version>
</dependency>
</dependencies>
</plugin>
Everything is also added to Eclipse project settings, so when I change something in my Dagger module, it is reflected automatically in the generated Java files under
target/generated-sources/annotations
This folder is also attached as a source folder to the project.
So far so good, when I run application via ADT on the emulator I see an exception saying
06-21 09:51:17.983: E/AndroidRuntime(1207):
java.lang.RuntimeException: Unable to create application XXX:
java.lang.IllegalStateException: Module adapter for class XXX could not be loaded.
Please ensure that code generation was run for this module.
As far as I understand it means that folder "target/generated-sources/annotations" is not visible for ADT when it tries to compile the project.
Currently I have 2 ideas:
Unfortunately, I have not found how to do either of those. Dagger documentation is also a bit too brief and obscure on this topic.
So how does it usually work in Eclipse, when you use Maven and Dagger?
UPDATE: I've done all the steps from the "possible duplicate" question above, but my problem is not solved. I will state this again: the files are created during build, they are just not visible to emulator for some reason.
Upvotes: 2
Views: 1286
Reputation: 3305
If anyone stucks with the same problem, here is how I solved it. I added next lines to pom.xml:
<build>
<outputDirectory>bin/classes</outputDirectory>
...
This means that all the usual stuff continues to go to "target" folder as usual during build, but all the classes from all the source folders go to "bin/classes". This must be set for ADT to work correctly. I don't know, if ADT can work with any other folder for classes, but by default it cannot. Now you can right click project and choose "Maven/Update Project..." to set all the output folders to "bin/classes". This fixes the problem, ADT runs application properly on the emulator with all the required classes.
Upvotes: 3