Skip to content
This repository was archived by the owner on Aug 20, 2025. It is now read-only.
This repository was archived by the owner on Aug 20, 2025. It is now read-only.

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

@ber4444

Description

@ber4444

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);
    }
  }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions