Getting a really strange issue; hopefully you guys can help.
I have been using Immutables library in my android project since a long time and had no issues. The auto-generated files for Immutable objects are located in (as example) build/generated/source/apt/debug/com/package/name/ImmutableClass.java
and the project compiles and works fine.
I recently decided to use Dependency Injection in the same project and started using Dagger 2. I have used Guice in another Java project (non-Android), but never used Dagger before. All of a sudden, I am starting to get weird errors saying that the Immutables class could not be found.
Error: error: cannot find symbol class ImmutableClass
.
I tried removing the @Component
and @Module
that I created and the errors went away. The funny thing is that the file ImmutableClass.java
is still there in the same location as earlier.
Please let me know your thoughts. Thanks.
Dagger 2 can indeed produce strange error messages when combined with other code gen libs.
If you look deeper into the errors then you'll probably find another one that says "cannot find symbol class DaggerXXXComponent" (or something similar).
You most probably have some issue that makes Dagger pre-processor to fail. Then, since Dagger fails, other code gen won't run, including Immutables.
You need to debug errors that cause Dagger failure and then Immutables errors will go away as well.