android–Dagger2没有生成Dagger *类

android–Dagger2没有生成Dagger *类,第1张

概述正如标题所说,Dagger2没有为我的Android项目生成Dagger*前缀类.我查看了我能找到的所有其他类似帖子,但没有任何帮助.我正在尝试将它添加到现有项目中,并且我遇到了一些初始问题,使其能够很好地处理数据绑定,但我似乎已经对其进行了排序,即数据绑定没有编译错误,并且它为它生成代

正如标题所说,Dagger2没有为我的Android项目生成Dagger *前缀类.我查看了我能找到的所有其他类似帖子,但没有任何帮助.我正在尝试将它添加到现有项目中,并且我遇到了一些初始问题,使其能够很好地处理数据绑定,但我似乎已经对其进行了排序,即数据绑定没有编译错误,并且它为它生成代码.我还下载了几个工作正常的示例项目.

我的顶级graddle文件有

    classpath 'com.neenbedankt.gradle.plugins:androID-apt:1.8'

而我的构建级别有

apply plugin: 'com.neenbedankt.androID-apt'....final DAGGER_VERSION = '2.8'....    compile 'javax.inject:javax.inject:1'    compile 'javax.annotation:javax.annotation-API:1.2'    apt "com.Google.dagger:dagger:$DAGGER_VERSION"    compile "com.Google.dagger:dagger:$DAGGER_VERSION"}

组件文件非常简单

@Singleton@Component(modules = {        AndroIDModule.class})public interface ApplicationComponent {    voID inject(MainActivity activity);}

AndroIDModule文件包含

@Modulepublic class AndroIDModule {    private final Context application;    public AndroIDModule(Application application) {        this.application = application;    }}

和Application类有

import com.rockwellcollins.fsl.dagger.DaggerApplicationComponent;...public class FslApplication extends Application {    private static ApplicationComponent component;    @OverrIDe    public voID onCreate() {        super.onCreate();        component = DaggerApplicationComponent.builder()                .androIDModule(new AndroIDModule(this))                .build();    }    public static voID inject(MainActivity target) {        component.inject(target);    }    public ApplicationComponent getComponent() {        return component;    }}

我得到的输出是

information:Gradle tasks [clean, :androID-slIDing-layer-lib:library:generateDeBUGSources, :androID-slIDing-layer-lib:library:mockableAndroIDJar, :androID-slIDing-layer-lib:library:prepareDeBUGUnitTestDependencIEs, :androID-slIDing-layer-lib:library:generateDeBUGAndroIDTestSources, :androID-slIDing-layer-lib:library:compileDeBUGSources, :androID-slIDing-layer-lib:library:compileDeBUGUnitTestSources, :androID-slIDing-layer-lib:library:compileDeBUGAndroIDTestSources, :mobile:generateDeBUGSources, :mobile:mockableAndroIDJar, :mobile:prepareDeBUGUnitTestDependencIEs, :mobile:generateDeBUGAndroIDTestSources, :mobile:compileDeBUGSources, :mobile:compileDeBUGUnitTestSources, :mobile:compileDeBUGAndroIDTestSources, :wear:generateDeBUGSources, :wear:generateDeBUGAndroIDTestSources, :wear:mockableAndroIDJar, :wear:prepareDeBUGUnitTestDependencIEs, :wear:compileDeBUGSources, :wear:compileDeBUGAndroIDTestSources, :wear:compileDeBUGUnitTestSources]Warning:WARNING: Dependency org.Json:Json:20131018 is ignored for deBUG as     it may be conflicting with the internal version provIDed by AndroID.Warning:WARNING: Dependency org.Json:Json:20131018 is ignored for release as it may be conflicting with the internal version provIDed by AndroID.Warning:VIEw fIEld aircraftList collIDes with a variable or importWarning:VIEw fIEld groundList collIDes with a variable or importC:\Git\androID\mobile\src\main\java\com\rockwellcollins\fsl\FslApplication.javaError:(7, 38) error: cannot find symbol class DaggerApplicationComponentError:org.gradle.API.internal.tasks.compile.CompilationFailedException: Compilation Failed; see the compiler error output for details.information:BUILD Failed

正如我所说,Dagger的东西根本没有代码生成.如果有人能指出问题是什么,我将非常感激.

解决方法:

你的依赖应该是

apt "com.Google.dagger:dagger-compiler:$DAGGER_VERSION"

您缺少工件ID的-compiler部分.

此链接还包含一些有用的信息.
https://github.com/google/dagger#android-gradle

总结

以上是内存溢出为你收集整理的android – Dagger2没有生成Dagger *类全部内容,希望文章能够帮你解决android – Dagger2没有生成Dagger *类所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1108597.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-29
下一篇 2022-05-29

发表评论

登录后才能评论

评论列表(0条)

保存