在Kotlin中评估表达式时出现java.lang.NoSuchFieldError

时间:2019-02-20 08:00:30

标签: java android kotlin

这是代码。如您所见,MainActivity中有一个字段dataBus

private lateinit var dataBus: LiveDataBus

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_main)

    dataBus = ViewModelProviders.of(this).get(LiveDataBus::class.java)
    val nameObserver = Observer<String> {
        nameTextView.text = it
    }
    dataBus.currentName.observe(this, nameObserver)

    change_content.setOnClickListener {
        dataBus.currentName.value = nameTextView.text.toString() + "Jack"
    }

}

我将break point放在了clickListener中。然后我在AndroidStudio中评估表达式dataBus,但是出现异常。

  

java.lang.NoSuchFieldError:找不到字段:MemberDescription(ownerInternalName = com / example / livedatabus / MainActivity,name = dataBus,desc = Lcom / example / livedatabus / LiveDataBus; isStatic = false)

0 个答案:

没有答案