warpath
warpath

Reputation: 11

Dagger2 Component not generated

I'm trying to set up a project with Dagger. Right now when I build,none of the Dagger* classes are generated for the Components.

Heres's my build.gradle config:

dependencies = [
    annotationProcessor 'com.google.dagger:dagger-compiler:2.11'
    provided            'org.glassfish:javax.annotation:10.0-b28'
    compile             'com.google.dagger:dagger:2.11'
]

and the code:

public class Person {
    private String name;

    @Inject
    public Person() {
        name = "summer";
    }

    public String getName() {
        return name;
    }
}

@Component
public interface AboutComponent {

    void inject(AboutActivity activity);
}

In Activity:

public class AboutActivity extends BaseActivity implements OnClickListener {
    @Inject Person mPerson;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // I can not find DaggerAboutComponent here
    }
}

I've tried rebuilding the project to see if it will generate the classes.

Upvotes: 0

Views: 1058

Answers (1)

warpath
warpath

Reputation: 11

Finally I find the reason.I import the Dagger dependencies in a Module "OpenSourceLibrary", which I manager the third party library. If i move the dependency to the Module of AboutLibrary, It works. But do I have to do it in every Module?

Upvotes: 1

Related Questions