0
我試圖理解Dagger2。我已經遵循了幾個例子,使用一個組件/模塊是有道理的,但添加一個混淆了我。我不能在我的應用程序類中使用多個組件嗎?在應用程序類中使用兩個Dagger組件
兩個匕首組件紅色突出顯示,並說「無法解析符號......」
public class MyApplication extends Application {
StorageComponent component;
ImageDownloaderComponent imageDownloaderComponent;
@Override
public void onCreate() {
super.onCreate();
component = DaggerStorageComponent
.builder()
.storageModule(new StorageModule(this))
.build();
imageDownloaderComponent = DaggerImageDownloaderComponent
.builder()
.imageDownloaderModule(new ImageDownloaderModule(this))
.build();
}
public StorageComponent getComponent() {
return component;
}
public ImageDownloaderComponent getImageDownloaderComponent() {
return this.imageDownloaderComponent;
}
}
你可以在我的應用程序類使用一個以上的組件。嘗試改變返回imageDownloaderComponent;並重建您的項目。 – eurosecom