Reputation: 359
Here is the Gradle :
plugins {
id "net.ltgt.apt" version "0.10"
}
group 'hello'
version '1.0-SNAPSHOT'
apply plugin: 'java'
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
compile 'com.google.dagger:dagger:2.11'
apt 'com.google.dagger:dagger-compiler:2.11'
}
And here are the classes :
Component :
import dagger.Component;
/**
* Created by bart on 27/06/2017.
*/
@Component(modules = {MainModule.class})
public interface MainComponent {
Service myService();
void inject(Manager aManager);
}
When I launch the ./gradlew build in the console, all is compiled OK. I don't get why I do not have access to DaggerMainComponent class or any Dagger* class in my Manager class.
Upvotes: 1
Views: 397
Reputation: 1673
Make sure your Annotation Processor is turned on. File -> Settings -> Build, Execution, Deployment -> Compiler -> Annotation Processor Click on "Enable annotation processor and choose obtain processors from project classpath
and here is what my .gradle file looks like
plugins {
id 'java'
id 'net.ltgt.apt-idea' version "0.15"
}
group 'DaggerExample'
version '1.0-SNAPSHOT'
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
implementation 'com.google.dagger:dagger:2.23.2'
annotationProcessor 'com.google.dagger:dagger-compiler:2.23.2'
}
This is all what necessary to make dagger run.
Upvotes: 1