简体   繁体   中英

Dagger2: cannot find symbol class Dagger*Component

I am looking into this example: https://github.com/amitshekhariitbhu/Android-MVP-Sample-Application

When I try to convert that project to Kotlin by clicking on --> Code --> Convert Java file to Kotlin file for some files..

I get:

error: cannot find symbol class DaggerActivityComponent for BaseActivity.java

error: cannot find symbol class DaggerApplicationComponent for MyApplication.java

Whats wrong?

You will need the following in build.gradle file:

apply plugin: 'kotlin-kapt'
…
dependencies {
    …
    final dagger_version = '2.17'
    implementation "com.google.dagger:dagger:$dagger_version"
    kapt "com.google.dagger:dagger-compiler:$dagger_version"
    compileOnly 'javax.annotation:javax.annotation-api:1.3.2'
}

For a complete step by step guide, see https://medium.com/@xiwei/simplest-dagger-example-920bbd10258

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM