在我的应用程序中使用dagger,我想在方法中注入类,但它显示编译时错误
fun someMethod(){
@Inject
val testClass : TestClass
}
它显示我的错误
This annotation is not applicable to local variable
任何帮助如何处理这个?
注入元素在活动或片段中应该是全局的
@Inject
lateint var testClass : TestClass //global declaration
fun someMethod(){
testClass.dosomething()
}