google / dagger

A fast dependency injector for Android and Java.
https://dagger.dev
Apache License 2.0
17.42k stars 2.01k forks source link

java.lang.NoSuchMethodError in attempt to make the project #114

Closed westward closed 9 years ago

westward commented 9 years ago

Hi, Yesterday I finished migrating my project to Dagger2 from Dagger1, except a few errors with @Singleton annotations. I commented all of them, project was built and successfully launched on Android emulator and I leave the resolving an issue with singleton annotation for today's evening. Unfortunately today, when I uncommented back @Singleton annotations in the application-wide @Component interface and tried to build the project, it fails with the following message:

Error:Execution failed for task ':nt2:compileDebugJava'.

java.lang.NoSuchMethodError: com.google.auto.common.MoreTypes.asTypeElements(Ljavax/lang/model/util/Types;Ljava/lang/Iterable;)Lcom/google/common/collect/ImmutableSet;

Attempts to clean, rebuild, invalidate project, comment @Singleton annotations back was unsuccessful. I can delete AppComponent.java file, but in this case compiler complains for missed class that it can resolve in module, application and activity classes.

I noticed that MoreTypes is a class of com.google.auto project. Checked its sources on GitHub and can't find the method asTypeElements() with 2 arguments of type Types and Iterable. Looks like AndroidStudio downloaded the (latest?) snapshot version of com.google.auto project to resolve dependency required by Dagger2, but two-argument version of AsTypeElements method is no more present there.

Can you please provide any solution to fix this issue?

JakeWharton commented 9 years ago

Dupe #113.