大家好,我正在尝试使用 Dagger-Hilt,我想知道如何实现下面的代码?
@AndroidEntryPoint
abstract class BaseActivity <B : ViewDataBinding, VM : ViewModel> : IActivity<VM>, AppCompatActivity() {
@Inject
lateinit var someClass: SomeClass
}
Gradle 返回此错误:
BaseActivity_GeneratedInjector.java:10: error: <identifier> expected
topLevelClass = BaseActivity<B, VM>.class
^error: [Hilt]
class java.lang.NullPointerException: java.lang.NullPointerException
这是生成的 Java 类:
@OriginatingElement(
topLevelClass = BaseActivity<B, VM>.class
)
@GeneratedEntryPoint
@InstallIn(ActivityComponent.class)
@Generated("dagger.hilt.android.processor.internal.androidentrypoint.InjectorEntryPointGenerator")
public interface BaseActivity_GeneratedInjector {
void injectBaseActivity(BaseActivity baseActivity);
}
帮助将不胜感激。