美文网首页
Dagger does not support injectio

Dagger does not support injectio

作者: 晓晓桑 | 来源:发表于2019-07-29 11:20 被阅读0次
场景

当java转成kotlin之后,dagger报错:Dagger does not support injection into private fields

原因

Kotlin 生成.java文件时属性默认为 private,而Dagger在@Inject成员不能是private的,否则会报:Error:(35, 29) 错误: Dagger does not support injection into private fields。

解决

bug代码:

   @Inject
    internal var mGson: Gson? = null

改成:

  @set:Inject
   internal var mGson: Gson? = null

相关文章

网友评论

      本文标题:Dagger does not support injectio

      本文链接:https://www.haomeiwen.com/subject/eeivrctx.html