问题:
我没有看到任何Dagger生成的Components
类。我已经执行了clean
,rebuild
,make 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);
}