小编Fir*_*enk的帖子

Dagger2不会生成"Dagger_"文件

我一段时间使用匕首2,但今天尝试编译得到了这个错误:

错误:(13,31)错误:找不到符号类Dagger_GlobalComponent

错误:(38,21)错误:找不到符号变量Dagger_GlobalComponent

所以这是代码:

public class MyAppApplication extends Application {

private static GlobalComponent component;

@Override
public void onCreate() {
    super.onCreate();

    component = Dagger_GlobalComponent.builder()
            .busModule(new BusModule())
            .syncModule(new SyncModule())
            .serviceModule(new ServiceModule())
            .contextModule(new ContextModule(this))
            .persistenceModule(new PersistenceModule(this))
            .build();
}}
Run Code Online (Sandbox Code Playgroud)

和gradle依赖:

...
compile 'com.google.dagger:dagger:2.0-SNAPSHOT'
apt 'com.google.dagger:dagger-compiler:2.0-SNAPSHOT'
provided 'org.glassfish:javax.annotation:10.0-b28'
...
Run Code Online (Sandbox Code Playgroud)

有解决方案吗 已经尝试过:清理,重建,更改依赖版本,还删除Gradle缓存并重新安装Android Studio.

如果它有助于此示例项目也出现相同的错误:

https://github.com/gk5885/dagger-android-sample

https://github.com/mgrzechocinski/dagger2-example

android dependency-injection dagger-2

21
推荐指数
3
解决办法
2万
查看次数

标签 统计

android ×1

dagger-2 ×1

dependency-injection ×1