2016-05-31 231 views
1

当添加依赖/子组件时,我遇到了Dagger 2的一个问题,它将使我无法找到DaggerAppComponent/DaggerBComponent/DaggerCComponent的find符号类。Dagger 2:在使用子组件/相关组件时找不到符号类

的组件,如:

public class ApplicationComponent { 
@Singleton 
@Component(modules= {...}) 
public interface AppComponent { 
    SomeManager someManager(); 
    void inject(Application application); 
} 
} 

@UserScope 
@Component(modules = {...}, dependencies = ApplicationComponent.AppComponent.class) 
public interface BComponent{ 
    CComponent plus (AModule aModule, BModule bModule); 
    void inject (SomeActivity someActivity); 
} 

@PerFragment 
@Subcomponent (modules = {AModule.class,BModule.class}) 
public interface CComponent { 
    void inject (SomeFragment someFragment); 
} 

每当我加方法添加到BComponent,我得到的错误找不到每当我试图建立匕首生成的类的所有3个符号类。如果我注释出加法,它确实会生成。有什么我做错了吗?

+0

是什么版本Dagger2的你在用吗? – EpicPandaForce

+0

Dagger 2.2编译器,Dagger 2.2,带有jsr250批注依赖项。 – hakuteru

+0

我不知道是否更新到Dagger 2.4会修复它,虽然有可能你必须添加'apt'com.google.guava:guava:19.0''才能正常工作 – EpicPandaForce

回答

1

我都面临着同样的问题时,子组件库中的项目,我忘了这行库/的build.gradle

apply plugin: 'com.android.library' 
apply plugin: 'com.neenbedankt.android-apt' 
... 
... 
dependencies { 
    ... 
    apt 'com.google.dagger:dagger-compiler:2.5' 
} 

希望这将帮助你

相关问题