没有生成DaggerComponents

时间:2016-11-08 14:41:38

标签: android dagger

问题:

我没有看到任何Dagger生成的Components类。我已经执行了cleanrebuildmake project但仍然无法获得它们。我没有使用com.neenbedankt.android-apt插件,因为Gradle 2.2.2并不需要它。

Android Studio Version: 2.2.2
Gradle Plugin Version: 2.2.2
Gradle Wrapper: 2.14.1

匕首:

compile 'com.google.dagger:dagger:2.7'
annotationProcessor 'com.google.dagger:dagger-compiler:2.7'

应用

public class EventsApplication extends Application
{
    private AuthenticationComponent authenticationComponent;

    @Override
    public void onCreate()
    {
        super.onCreate();
        initDaggerComponents();
    }

    private void initDaggerComponents()
    {
        // I'm suppose to use Dagger generated Components here but there aren't any created.
    }

    public AuthenticationComponent getAuthenticationComponent()
    {
        return authenticationComponent;
    }
}

ApplicationModule:

@Module
@SuppressWarnings("unused")
public class ApplicationModule
{
    private final EventsApplication application;

    public ApplicationModule(final EventsApplication application)
    {
        this.application = application;
    }

    @Provides
    @Singleton
    @ForApplication
    Context provideApplicationContext()
    {
        return application;
    }
}

AuthenticationModule:

@Module
@SuppressWarnings("unused")
public class AuthenticationModule
{
    @Provides
    MSAAuthAndroidAdapter provideAuthenticationAdapter(final EventsApplication eventsApplication)
    {
        return new MSAAuthAndroidAdapter(eventsApplication)
        {
            @Override
            public String getClientId()
            {
                return "";
            }

            @Override
            public String[] getScopes()
            {
                return new String[]{};
            }
        };
    }
}

AuthenticationComponent:

@SuppressWarnings("unused")
@Component(modules = {AuthenticationModule.class})
public interface AuthenticationComponent
{
    void inject(final SignInActivity activity);
}

0 个答案:

没有答案