【发布时间】:2021-10-24 18:01:12
【问题描述】:
为什么下面的代码模板会出现空指针异常?我做错了什么或留下来做什么?
注释
@Qualifier
@Retention(RetentionPolicy.RUNTIME)
public @interface MyAnnotation {}
模块
@Module
@InstallIn(ActivityComponent.class)
public interface MyModule {
@Provide
@MyAnnotation
public static ConfirmationOverlay provideConfirmation() {
return new ConfirmationOverlay();
}
}
如下所示
@Inject @MyAnnotation Provide<ConfirmationOverlay> confOverlay;
............
private void aMethod() {
confOverlay.get(); ======> throws null pointer exception
}
【问题讨论】:
标签: java android nullpointerexception dagger