dagger 2.2를 사용하기 시작했고 컴포넌트 빌더의 모듈 메소드는 더 이상 사용되지 않습니다.
이것은 내 응용 프로그램 구성 요소입니다.
@Component(modules = ApplicationModule.class)
public interface ApplicationComponent {
void inject(Application application);
}
그리고 애플리케이션 모듈 :
@Module
public class ApplicationModule {
Application application;
public ApplicationModule(Application application) {
this.application = application;
}
@Provides
@Singleton
Application providesApplication() {
return application;
}
}
생성 된 클래스는 다음과 같습니다.
@Generated(
value = "dagger.internal.codegen.ComponentProcessor",
comments = "https://google.github.io/dagger"
)
public final class DaggerApplicationComponent implements ApplicationComponent {
private DaggerApplicationComponent(Builder builder) {
assert builder != null;
}
public static Builder builder() {
return new Builder();
}
public static ApplicationComponent create() {
return builder().build();
}
@Override
public void inject(Application application) {
MembersInjectors.<Application>noOp().injectMembers(application);
}
public static final class Builder {
private Builder() {}
public ApplicationComponent build() {
return new DaggerApplicationComponent(this);
}
/**
* @deprecated This module is declared, but an instance is not used in the component. This method is a no-op. For more, see https://google.github.io/dagger/unused-modules.
*/
@Deprecated
public Builder applicationModule(ApplicationModule applicationModule) {
Preconditions.checkNotNull(applicationModule);
return this;
}
}
}
ComponentBuilder를 사용하지 않는 경우 어떻게 구성 요소를 초기화합니까?