无法解析符号DaggerApplicationComponent [英] Can not resolve symbol DaggerApplicationComponent

查看:118
本文介绍了无法解析符号DaggerApplicationComponent的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将Dagger2与Java一起使用,并得到无法在应用程序中解析符号DaggerApplicationComponent错误。依赖项似乎有问题。任何帮助将非常感激。
我的完整代码在这里-
https://github.com/rohitku860/AndroidMvpDagger2

I use Dagger2 with java and I got "Can not resolve symbol DaggerApplicationComponent error in my application." Seems there is something wrong with dependencies. Any help would be really appreciated. My complete code is here- https://github.com/rohitku860/AndroidMvpDagger2

这是我的依赖项应用程序:

Here is my app graddle with dependencies:

 apply plugin: 'com.android.application'
    android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "com.example.android.androidmvpdagger2"
        minSdkVersion 16
        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'
        }
    }
}

    dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.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.google.dagger:dagger:2.13'
    annotationProcessor 'com.google.dagger:dagger-compiler:2.13'
    implementation 'com.jakewharton:butterknife:8.5.1'
    annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1'

}

这是项目一:

        buildscript {

        repositories {
            google()
            jcenter()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:3.1.0'
        }
    }

        allprojects {
        repositories {
            google()
            jcenter()
        }
    }



           task clean(type: Delete) {
            delete rootProject.buildDir
        }


推荐答案

此错误与您的Gradle配置无关。

This error is not related to your Gradle configuration.

DaggerApplicationComponent 是Dagger为<$ c $生成的一个类。您定义的c> ApplicationComponent 接口。如果在代码生成过程中出现任何错误(例如,缺少 @Provides 方法),则Dagger将不会生成 DaggerApplicationComponent ,并且您会会得到此错误。

DaggerApplicationComponent is a class that Dagger generates for ApplicationComponent interface that you defined. If there is any error during code generation (e.g. missing @Provides method), Dagger will not generate DaggerApplicationComponent and you'll get this error.

您需要做的是读取AndroidStudio中的整个错误输出,并尝试了解Dagger为何失败。

What you need to do is to read the entire error output in AndroidStudio and try to understand why Dagger failed.

当项目文件中缺少某些导入语句时,我也遇到了非常讨厌的行为。在这种情况下,Dagger会失败,但不会确切告诉您问题出在哪里,您需要自己寻找问题。

I also encountered a very nasty behavior when some import statements were missing in project files. In these cases Dagger will fail, but will not tell you exactly what the problem is and you'll need to look for it by yourself.

如果您需要进一步的帮助-将生成错误输出附加到问题上。

If you need further help - attach the build error output to the question.

这篇关于无法解析符号DaggerApplicationComponent的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆