1 year ago

#350788

test-img

Abhishek Dutt

Getting an Unresolved reference when DaggerActivityComponent is called inside an activity

I have the following project-level build.gradle file:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext.kotlin_version = '1.6.10'
    repositories {
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:7.1.2'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

plugins {
    id 'com.android.application' version '7.1.1' apply false
    id 'com.android.library' version '7.1.1' apply false
    id 'org.jetbrains.kotlin.android' version '1.6.10' apply false
}


task clean(type: Delete) {
    delete rootProject.buildDir
}

And I am using the following dependency for dagger:

implementation 'com.google.dagger:dagger:2.28.3'
    annotationProcessor 'com.google.dagger:dagger-compiler:2.24'
    annotationProcessor 'com.google.dagger:dagger-android-processor:2.24'
    implementation 'com.google.dagger:dagger-android-support:2.27'

But when I try to call the DaggerActivityComponent in my Activity, I get a compile time error:

Unresolved reference: DaggerActivityComponent

The ActivityComponent is as follows:

@ActivityScope
@Component(dependencies = [AppComponent::class])
interface ActivityComponent {

    fun inject(albumDetailsActivity: AlbumDetailsActivity)
}

So basically, I am calling the DaggerActivityComponent inside the AlbumDetailsActivity

The following is the appComponent :

@Singleton
@Component( modules = [ImgurApiModule::class])
interface AppComponent {

    fun inject(application: Application)

    fun getImgurApi(): ImgurAPI

}

android

dagger-2

0 Answers

Your Answer

Accepted video resources