Kotlin and Dagger: Can I use @Inject to an object still make it nullable/optional?

后端 未结 2 1462
心在旅途
心在旅途 2020-12-30 05:52

I need something that can make my class nullable/optional because of the runtime errors that is happening on some devices.

Is this possible?

class M         


        
2条回答
  •  北海茫月
    2020-12-30 06:48

    If you don't have Java code that needs to access the presenter field you don't need to annotate it with @JvmField. Instead, you can declare your field like so:

    @set:Inject
    var presenter: Presenter? = null
    

提交回复
热议问题