Unresolved reference dagger 2 + kotlin + android gradle

前端 未结 1 990
执笔经年
执笔经年 2021-02-19 11:42

I\'m testing out Dagger 2 with Kotlin in an Android project. I was inspired by the Android Clean Architecture repo. I have two modules in my gradle build, one is \"app\" and o

1条回答
  •  醉梦人生
    2021-02-19 12:18

    Your module/build.gradle is set to java instead of kotlin. I have modified it to the following and it compiles ok.

    buildscript {
        repositories {
            jcenter()
            mavenCentral()
        }
        dependencies {
            classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:0.12.1218'
        }
    }
    
    apply plugin: 'kotlin'
    
    dependencies {
        kapt "com.google.dagger:dagger-compiler:2.0.1"
        compile "com.google.dagger:dagger:2.0.1"
        compile "javax.annotation:javax.annotation-api:1.2"
        compile "org.jetbrains.kotlin:kotlin-stdlib:0.12.1218"
    }
    

    0 讨论(0)
提交回复
热议问题