Im using dagger 2 since a while, but today trying to compile got this error:
Error:(13, 31) error: cannot find symbol class Dagger_GlobalComponent
Error:(38, 21) error: cannot find symbol variable Dagger_GlobalComponent
So here is the code:
public class MyAppApplication extends Application {
private static GlobalComponent component;
@Override
public void onCreate() {
super.onCreate();
component = Dagger_GlobalComponent.builder()
.busModule(new BusModule())
.syncModule(new SyncModule())
.serviceModule(new ServiceModule())
.contextModule(new ContextModule(this))
.persistenceModule(new PersistenceModule(this))
.build();
}}
And gradle dependencies:
...
compile 'com.google.dagger:dagger:2.0-SNAPSHOT'
apt 'com.google.dagger:dagger-compiler:2.0-SNAPSHOT'
provided 'org.glassfish:javax.annotation:10.0-b28'
...
Any solutions? Already tried to: Clean, Rebuild, Change dependecy versions, also deleting the Gradle cache and reinstalling Android Studio.
If it helps also got the same error with this sample projects:
https://github.com/gk5885/dagger-android-sample
https://github.com/mgrzechocinski/dagger2-example
I was trying to follow the Dagger2 tutorial on tutsplus here and ran into the same issue when trying to use the underscore syntax (Dagger_ClassnameComponent).
As others have stated, the new Dagger APIs don't use that underscore syntax, but rather just use the syntax DaggerClassnameComponent. However, on attempting to use the new syntax in my simple app, the class DaggerClassnameComponent was not found. I believe it should be located in the app/build/generated/source/apt/debug/packagename/component folder.
At first, I didn't have any files generated under the above mentioned folder. However, my solution was to clean and build the project, and then I could use the Component class as expected.
Dagger 2 has now been released, so you'll need to change your gradle dependencies:
compile 'com.google.dagger:dagger:2.0'
provided 'com.google.dagger:dagger-compiler:2.0'
provided 'org.glassfish:javax.annotation:10.0-b28'
Looks like they removed the underscore from the generated stuff. See Dagger2 generated class is all of a sudden missing from Android Studio.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With