android - 错误 : cannot find symbol class DaggerAppComponent version conflict with other dependencies

标签 android dependency-injection dagger

我在构建 android 项目时收到“错误:找不到符号类 DaggerAppComponent” ,我将 Dagger 和其他依赖项的版本更改为最新版本,我也厌倦了旧版本 但仍然出现同样的错误。

我的build.gradle文件

 // ButterKnife libraries
implementation 'com.jakewharton:butterknife:10.2.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.0'

// Dagger 2 libraries


implementation "com.google.dagger:dagger:2.11"
annotationProcessor "com.google.dagger:dagger-compiler:2.11"

// Components for Android
implementation group: 'com.google.android.material', name: 'material', version: '1.2.0-alpha01'

// Networking
implementation 'com.squareup.retrofit2:retrofit:2.6.2'
implementation 'com.squareup.retrofit2:converter-gson:2.6.2'
implementation 'com.squareup.okhttp3:logging-interceptor:4.2.2'
implementation 'com.squareup.okhttp3:okhttp:4.2.2'
implementation 'com.squareup.retrofit2:adapter-rxjava:2.6.2'

// gogole support design
implementation 'com.android.support:design:29.0.0'

// Lombok for pojo
implementation 'org.projectlombok:lombok:1.18.10'
annotationProcessor 'org.projectlombok:lombok:1.18.10'

//Rx java and Rx android
implementation 'io.reactivex:rxjava:1.3.1'
implementation 'io.reactivex:rxandroid:1.1.0'

//Realm local DB
implementation 'io.realm:android-adapters:1.2.0'

//SmileyRating Bar
implementation 'com.github.sujithkanna:smileyrating:1.6.8'

最佳答案

这里我收到错误找不到符号类 DaggerAppComponent

 public class Injector {

    // Singleton instance
    private static Injector instance;

    // components
    private AppComponent appComponent;

    // Private constructor to make it singleton
    private Injector() {
    }

    /**
     * Get the singleton Injector instance
     *
     * @return Injector
     */
    private static Injector instance() {
        if (instance == null) {
            instance = new Injector();
        }
        return instance;
    }

    /**
     * Creates application component which is used of injection later.
     *
     * @param application
     */
    public static void createApplicationComponent(Application application) {
        if (instance().appComponent == null) {
            instance().appComponent = DaggerAppComponent.builder()
                    .appModule(new AppModule(application))
                    .build();
        }
    }

    /**
     * Returns the component for injection.
     *
     * @return
     */
    public static AppComponent component() {
        return instance().appComponent;
    }
}

关于android - 错误 : cannot find symbol class DaggerAppComponent version conflict with other dependencies,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58973773/

相关文章:

带有 Dagger 的 Android Gradle 构建问题

android - 在 minSdkVersion ="4"应用程序中继承自 @android :style/Theme. Holo.Light

java - Android:无法解析类型java.lang.Enum

java - 如何在android中构建一个不断增长的表单

jsf - 如何在 SesionScoped bean 中使用 ViewScoped bean?

c# - 使用 Microsoft Asp.NET 依赖注入(inject)时找不到 HttpActionContext.get_Request() 方法

android - 在不同的 Activity 中注入(inject) ViewModelFactory

android - : Landroid/arch/core/executor/AppToolkitTaskExecutor 解析失败

android - 注入(inject)演示者子类以查看android

android - Dagger 代码在 Android 仪器测试中给出 NoClassDefFoundError,但在正常应用程序中有效