Search code examples
javaandroiddagger-2

Dagger 2 Component class not generated


i'm currently learn dagger2 but i have problem is daggercomponent class not generated and i can't know the reason

implementation 'com.google.dagger:dagger-android:2.27'
implementation 'com.google.dagger:dagger-android-support:2.27'  
annotationProcessor 'com.google.dagger:dagger-android-processor:2.27'

public class Nugets {
    @Inject
    public Nugets() {
    }
}

public class Water {

    @Inject
    public Water() {
    }
}

public class Coffee {

    Nugets nugets;
    Water water;

    @Inject
    public Coffee(Nugets nugets, Water water) {
        this.nugets = nugets;
        this.water = water;
    }
}

@Component
public interface CoffeeComponent {
    Coffee getCoffee();
}

when i tried to to find DaggerCoffeeComponent class i didn't find it. note i rebuild project


Solution

  • You have to implementation dagger instead of dagger-android. Don't forget to make project or rebuild

    implementation 'com.google.dagger:dagger:2.27'
    annotationProcessor 'com.google.dagger:dagger-compiler:2.27'