Multiple dex files define lcom/squareup/javawriter/JavaWriter$Scope; When attempting to compile with Dagger and dagger-compiler… here is a solution to the problem.
Multiple dex files define lcom/squareup/javawriter/JavaWriter$Scope; When attempting to compile with Dagger and dagger-compiler
I have these in my app module build.gradle
compile 'com.squareup.dagger:dagger:1.2.2'
compile 'com.squareup.dagger:dagger-compiler:1.2.2'
When I try to build, I get the above exception ( http://i.imgur.com/PMTZwWq.png ).
If I don’t include the compiler I get:
Module adapter for class .... AndroidModule could not be loaded. Please ensure that code generation was run for this module.
Why does this exception occur and how should I fix it?
I’m using Android Studio.
Solution
Change
compile 'com.squareup.dagger:dagger-compiler:1.2.2'
to
provided 'com.squareup.dagger:dagger-compiler:1.2.2'
Solved the problem.