我不断收到以下错误:
error: cannot find symbol
DatastoreComponent component = DaggerDatastoreComponent.create();
^
在我的gradle文件中,我按如下方式导入dagger2
//dagger 2
implementation 'com.google.dagger:dagger:2.14.1'
annotationProcessor 'com.google.dagger:dagger-compiler:2.14.1'
//to enable DaggerActivity, DaggerBroadcastReceiver, DaggerFragment etc classes
implementation 'com.google.dagger:dagger-android:2.14.1'
annotationProcessor 'com.google.dagger:dagger-android-processor:2.14.1'
//support libraries with dagger 2
implementation 'com.google.dagger:dagger-android-support:2.14.1'
我有一个名为DatastoreComponent的接口:
import dagger.Component;
@Component
public interface DatastoreComponent {
Datastore getDatastore();
}
在MainActivity类中,我有以下内容:
@Inject
private Datastore mDatastore;
@Override
protected void onCreate(Bundle savedInstanceState) {
...
DatastoreComponent component = DaggerDatastoreComponent.create();
mDatastore = component.getDatastore();
...
}
为什么会给我这个错误?我究竟做错了什么?
谢谢