DaggerAppComponent在Kotlin中有未解决的引用

时间:2019-01-10 20:07:25

标签: kotlin

请帮帮我。我已经尝试了所有方法来解决此问题,但没有结果:(有关我的应用程序的更多信息 build.gradle(Module:app)

apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

apply plugin: 'io.fabric'

apply plugin: 'kotlin-kapt'
buildscript {
repositories {
    maven { url 'https://maven.fabric.io/public' }
}
dependencies {
    // You can find the lastest version number here: 
https://docs.fabric.io/android/changelog.html#fabric-gradle-plugin
    classpath 'io.fabric.tools:gradle:1.+'
}
}

project.ext {
supportLibraryVersion = "26.1.0"
androidArchVersion = "1.0.0-rc1"
daggerVersion = "2.11"
butterKnifeVersion = "8.7.0"
rxJavaVersion = "2.1.0"
rxAndroidVersion = "2.0.1"
timberVersion = "4.5.1"
priorityJobQueueVersion = "2.0.1"
playServicesVersion = "11.4.2"
retrofitVersion = "2.1.0"
okHttpVersion = "3.4.1"
rxRelayVersion = "2.0.0"
rxLintVersion = "1.6"
}

android {
compileSdkVersion 27
defaultConfig {

javaCompileOptions.annotationProcessorOptions.includeCompileClasspath = 
true
    vectorDrawables.useSupportLibrary true
    applicationId "***"
    minSdkVersion 21
    targetSdkVersion 27
    versionCode 1
    versionName "1.0"
    resConfigs "en"
    testInstrumentationRunner 
"android.support.test.runner.AndroidJUnitRunner"
}
splits {
    density {
        enable true

    }
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 
'proguard-rules.pro'
    }
    debug {
        // Disable fabric build ID generation for debug builds
        ext.enableCrashlytics = false
    }
}
}

kapt {
generateStubs = true
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'uk.co.chrisjenx:calligraphy:2.2.0'
implementation 'com.github.bumptech.glide:glide:3.7.0'
implementation 'com.android.support:design:27.0.2'
implementation 'com.intuit.sdp:sdp-android:1.0.5'

implementation('com.crashlytics.sdk.android:crashlytics:2.9.0@aar') {
    transitive = true
}



implementation 'com.android.support:support-v4:27.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-
core:3.0.1' 

implementation "com.android.support:appcompat-
v7:$project.supportLibraryVersion"

// Retrofit
implementation 'com.squareup.retrofit2:retrofit:2.4.0'
// GSON Converter
implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
implementation 'com.squareup.retrofit2:adapter-rxjava2:2.3.0'
//OkHttp Logging Interceptor
implementation 'com.squareup.okhttp3:okhttp:3.10.0'
implementation 'com.squareup.okhttp3:logging-interceptor:3.9.1'
implementation 'com.google.code.gson:gson:2.8.2'
// ReactiveX
implementation "io.reactivex.rxjava2:rxjava:$project.rxJavaVersion"
implementation 
"io.reactivex.rxjava2:rxandroid:$project.rxAndroidVersion"
//Room database
implementation "android.arch.persistence.room:runtime:1.1.1"
implementation "android.arch.persistence.room:rxjava2:1.1.1"
kapt "android.arch.persistence.room:compiler:1.1.1"
implementation "android.arch.paging:runtime:1.0.0-alpha3"
// Lifecycle
implementation 
"android.arch.lifecycle:runtime:$project.androidArchVersion"
implementation 
"android.arch.lifecycle:extensions:$project.androidArchVersion"
annotationProcessor 
"android.arch.lifecycle:compiler:$project.androidArchVersion"
// RxRelay
implementation 
"com.jakewharton.rxrelay2:rxrelay:$project.rxRelayVersion"
// RxLint
implementation "nl.littlerobots.rxlint:rxlint:$project.rxLintVersion"
// GCM Network Manager
implementation "com.google.android.gms:play-services-
gcm:$project.playServicesVersion"
// Priority Job Queue
implementation "com.birbit:android-priority-
jobqueue:$project.priorityJobQueueVersion"
// ButterKnife
implementation "com.jakewharton:butterknife:$project.butterKnifeVersion"
annotationProcessor "com.jakewharton:butterknife-
compiler:$project.butterKnifeVersion"
// Dagger
def daggerVer = 2.14
implementation "com.google.dagger:dagger:$daggerVer"
implementation "com.google.dagger:dagger-android-support:$daggerVer"
kapt "com.google.dagger:dagger-android-processor:$daggerVer"
kapt "com.google.dagger:dagger-compiler:$daggerVer"
// Timber
implementation "com.jakewharton.timber:timber:$project.timberVersion"

}

这是我的App,其中DaggerAppComponent为红色

class App : Application(), HasActivityInjector {
@Inject
lateinit var dispatchingAndroidInjector: DispatchingAndroidInjector<Activity>

override fun onCreate() {
    super.onCreate()
    if (BuildConfig.DEBUG) {
        Timber.plant(Timber.DebugTree())
    }


    DaggerAppComponent
            .builder()
            .application(this)
            .build()
            .inject(this)
    JobManagerFactory().getJobManager(this)
}

override fun activityInjector(): AndroidInjector<Activity> {
    return this.dispatchingAndroidInjector
}

}

Android Studio版本-3.0.1 我已在清单中注册了应用程序,并且多次重建和使缓存无效。 不明白是什么问题。请救救我:(

0 个答案:

没有答案