I have already added Dagger into my application. Now I am facing the following error after updating Android studio and project updated to the latest AndroidX version.
error: [RefersToDaggerCodegen] Don't refer to Dagger's internal or generated code
(see https://errorprone.info/bugpattern/RefersToDaggerCodegen)
How to solve this build error.
Edit: I am trying to inject dagger like the below
((App) appContext).getApplicationComponent().inject(this);
And inside of the interface
@SuppressWarnings({"RefersToDaggerCodegen"})
@Singleton
@Component(modules = {
ApplicationModule.class,
DatabaseModule.class,
NetworkModule.class,
QuranDataModule.class,
QuranPageModule.class } )
public interface ApplicationComponent {
@SuppressWarnings("RefersToDaggerCodegen")
void inject(QuranDataProvider quranDataProvider);
Edit 2 I have initialize the component like the following:
@SuppressWarnings("RefersToDaggerCodegen")
protected ApplicationComponent initializeInjector() {
return DaggerApplicationComponent.builder()
.applicationModule(new ApplicationModule(this))
.build();
}
Still facing the same issue.
The problem with my project is I am using dagger old version not too old but not latest. So I updated kotlin version and Dagger version to the following
kotlinVersion = '1.3.31'
daggerVersion = '2.15'
And in your gradle-wrapper.properties please update the distribution url like below
distributionUrl=https\://services.gradle.org/distributions/gradle-5.2-all.zip
And finally update the errorprone version also
classpath "net.ltgt.gradle:gradle-errorprone-plugin:0.8"
I have done all the above steps. Now I am able to build my application successfully.
Thanks for the help @EpicPandaForce