Dagger2组件问题

时间:2018-01-14 02:27:09

标签: android dependency-injection android-gradle dagger-2 dagger

我对匕首2的东西有些麻烦,任何帮助都会受到赞赏!

因此,在下图中列出了我在编译时遇到的错误: enter image description here

此处还有我的build.grade(Module:app)文件:

 apply plugin: 'com.android.application'

 android {
    compileSdkVersion 26
    buildToolsVersion '26.0.2'

    defaultConfig {
        applicationId "com.vasco.trackme"
        minSdkVersion 19
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        targetCompatibility 1.8
        sourceCompatibility 1.8
    }
}

ext {
    supportLibVersion = "26.1.0"
    daggerVersion = "2.11"
    goolePlayServiceVersion = "11.8.0"
    butterKnifeVersion = "8.8.1"
    retrofitVersion = "2.1.0"
    okhttpVersion = "3.7.0"
    okhttpLoggingVersion = "3.4.2"
    jodaTimeSerilialiserVersion = "1.2.0"
    timberVersion = "4.3.1"
    picasoVersion = "2.5.2"
    picasoDownloaderVersion = "1.1.0"
    rxLifeCycleVersion = "0.4.0"
    rxJavaBindingVersion = "1.0.0"
    rxJavaVersion = "1.2.5"
    rxAndroidVersion = "1.2.1"
}


dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation "com.android.support:design:${supportLibVersion}"
    implementation "com.android.support:preference-v14:${supportLibVersion}"
    implementation "com.android.support:cardview-v7:${supportLibVersion}"
    implementation "com.android.support:recyclerview-v7:${supportLibVersion}"

    //maps and location (avoiding the unnecessary stuff from the google play services lib)
    implementation "com.google.android.gms:play-services-maps:${goolePlayServiceVersion}"
    implementation "com.google.android.gms:play-services-location:${goolePlayServiceVersion}"

    //dagger
    implementation "com.google.dagger:dagger:${daggerVersion}"
    annotationProcessor "com.google.dagger:dagger-compiler:${daggerVersion}"

    //butterKnife
    implementation "com.jakewharton:butterknife:${butterKnifeVersion}"
    annotationProcessor "com.jakewharton:butterknife-compiler:${butterKnifeVersion}"

    //network
    implementation "com.squareup.okhttp3:okhttp:${okhttpVersion}"
    implementation "com.squareup.okhttp3:logging-interceptor:${okhttpLoggingVersion}"
    implementation "com.fatboyindustrial.gson-jodatime-serialisers:gson-jodatime-serialisers:${jodaTimeSerilialiserVersion}"

    //retrofit
    implementation "com.squareup.retrofit2:retrofit:${retrofitVersion}"
    implementation "com.squareup.retrofit2:converter-gson:${retrofitVersion}"
    implementation "com.squareup.retrofit2:adapter-rxjava:${retrofitVersion}"

    //timber
    implementation "com.jakewharton.timber:timber:${timberVersion}"

    //picaso
    implementation "com.squareup.picasso:picasso:${picasoVersion}"
    implementation "com.jakewharton.picasso:picasso2-okhttp3-downloader:${picasoDownloaderVersion}"

    //rx Life cycle
    implementation "com.trello:rxlifecycle:${rxLifeCycleVersion}"
    implementation "com.trello:rxlifecycle-components:${rxLifeCycleVersion}"

    //RxJava Binding
    implementation "com.jakewharton.rxbinding:rxbinding:${rxJavaBindingVersion}"

    //RxJava
    implementation "io.reactivex:rxjava:${rxJavaVersion}"
    implementation "io.reactivex:rxandroid:${rxAndroidVersion}"

    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:${supportLibVersion}"
    testImplementation 'junit:junit:4.12'
}

组件类:

@ApplicationScope
@Component(modules = {CommunicationServiceModule.class, DBModule.class,
        SharedPrefsModule.class, ActivityModule.class, PicasoModule.class})
public interface AppComponent {

    DBHelper getDBHelper();

    Preferences getPreferences();

    CommunicationService getCommunicationService();

    Picasso getPicasso();
}

@JourneyScope
@Component(modules = JourneyModule.class, dependencies = AppComponent.class)
public interface JourneyComponent {

    void injectFragment(JourneyFragment journeyFragment);
}

@MainActivityScope
@Component(modules = MainActivityModule.class, dependencies = AppComponent.class)
public interface MainActivityComponent {

    void injectActivity(MainActivity mActivity);

}

在编译时不应该生成“DaggerMainActivityComponent”吗? 怎么找不到? (怪异)

关于第二个错误我不知道是什么!!!

非常感谢

0 个答案:

没有答案