I'm probably missing something very basic here, so hopefully it's not a hard question.
My equivalent of
CoffeeShop coffeeShop = DaggerCoffeeShop.create();
is not being recognised by the IDE (IntelliJ). This is a native Java project. The "DaggerCoffeShop" part is all red.
The component is using this syntax:
@Component(modules = <ModuleClassName>.class)
public interface CoffeeShop {
// some methods.
// does it matter what goes in here for it to recognise the component?
}
The "ModuleClassName" is the name of a module annotated with @Module and includes @Provides methods.
To get the libs I'm using this in Gradle:
compile 'com.google.dagger:dagger:2.4'
compile 'com.google.dagger:dagger-compiler:2.4'
Is that all I need? I don't get any errors for any of the annotations, it's just this Dagger keyword it can't recognise. What am I missing?
Any help or direction appreciated. I'm not finding the documentation to be that great for beginners like me.
Your annotation processing is probably not enabled.
In Settings
- > Compiler
-> Annotation Processor
-> Enable annotation processing
Afterwards, Rebuild Project
If it still thinks the files don't exist (despite the app running properly), you'll have to add the generated source folder as a source folder: File
-> Project Structure
-> Modules
-> select your project -> Sources
-> right click on the generated folder with the Dagger stuff in it -> Sources
And compile 'com.google.dagger:dagger-compiler:2.4'
should be either apt
scoped or annotationProcessor
scoped. If you use Kotlin, then kapt
scoped
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