android - DaggerAppComponent - Unresolved reference

标签 android kotlin dagger

请帮我将 Dagger 2 连接到 Kotlin。
我的应用程序构建 gradle:

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'io.fabric'
apply plugin: 'kotlin-kapt'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "mobile.socialboards.com"
        minSdkVersion 21
        targetSdkVersion 28
        versionCode 19
        versionName '1.0'
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        debug {
            minifyEnabled false
        }
    }
    configurations {
        cleanedAnnotations
        compile.exclude group: 'org.jetbrains' , module:'annotations'
    }
    productFlavors {}
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = '1.8'
        freeCompilerArgs = ['-Xjvm-default=enable']
    }
    lintOptions {
        abortOnError false
    }
}

kapt {
    generateStubs = true
}

dependencies {
    ...

    implementation 'com.google.dagger:dagger-android:2.14.1'
    implementation 'com.google.dagger:dagger-android-support:2.14.1' // if you use the support libraries
    implementation "com.google.dagger:dagger:2.14.1"
    kapt 'com.google.dagger:dagger-android-processor:2.12'
    kapt "com.google.dagger:dagger-compiler:2.14.1"
    compileOnly "org.glassfish:javax.annotation:3.1.1"
}

apply plugin: 'com.google.gms.google-services'

我正在制作 sуnc,然后重建,但是

DaggerAppComponent



Android Studio 在我的应用程序 kotlin 类中找不到。我研究了很多文章-仍然不明白出了什么问题。请帮忙!

最佳答案

我已经实现了完整的 MVVM(Rx、Dagger、Kotlin),只需要这两个用于 dagger:

 implementation 'com.google.dagger:dagger:2.12'
kapt 'com.google.dagger:dagger-compiler:2.12'

如果有什么让我知道!!

关于android - DaggerAppComponent - Unresolved reference ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52077011/

相关文章:

android - 资源条目 com.crashlytics.android.build_id 已定义 - Android Studio

android - 在 Jetpack Compose 中单击时如何禁用涟漪效应

Android:将带有可播放视频的 Intent 发送到电报应用程序

android - 在 Android 上使用 DI 的具体好处是什么?

android - Dagger 2 第三方注入(inject) Android

安卓无限适配器

IDE 中的 Kotlin "no cast needed"

arrays - Kotlin 使用另一个数组初始化一个数组

kotlin - 一起运行时,测试会失败,但是单独运行会成功,即使在每次测试之前重新模拟实例

mvvm - 使用 Dagger 时我们真的需要 viewModelFactories 和 viewmodelProviders 吗?