dagger-reflect icon indicating copy to clipboard operation
dagger-reflect copied to clipboard

Cannot access 'Builder': it is private in 'DaggerApplicationComponent'

Open ber4444 opened this issue 5 years ago • 0 comments

Getting the above error with the "Full Reflection" approach.

val applicationComponent = Dagger.builder(DaggerApplicationComponent.Builder::class.java)
            .application(this)
            .build()
@ApplicationScope
@Component(modules = [ApplicationModule::class, ActivityLifecycleModule::class])
interface ApplicationComponent {

    val application: Application

    val myApplication: MyApplication

    @ApplicationScope
    val deviceInfo: DeviceInfo

    fun callbacks(): Set<Application.ActivityLifecycleCallbacks>

    @Component.Builder
    interface Builder {
        fun build(): ApplicationComponent

        @BindsInstance
        fun application(application: MyApplication): Builder
    }
}

because the generated class is indeed private:

  private static final class Builder implements ApplicationComponent.Builder {
    private AmexApplication application;

    @Override
    public Builder application(AmexApplication application) {
      this.application = Preconditions.checkNotNull(application);
      return this;
    }

    @Override
    public ApplicationComponent build() {
      Preconditions.checkBuilderRequirement(application, AmexApplication.class);
      return new DaggerApplicationComponent(new ApplicationModule(), new CoroutineCallbacksModule(), new LoggingCallbacksModule(), application);
    }
  }

ber4444 avatar Jun 10 '20 05:06 ber4444