NoSuchMethodError: java.lang.Long.hashCode

前端 未结 4 2127
暗喜
暗喜 2020-12-15 18:28

I have the following override of method on hashCode in AbstractORM class:

var _id = Random().nextLong()

override fun getId() = _id         


        
4条回答
  •  甜味超标
    2020-12-15 18:55

    Overriding the hashCode() function, as m0skit0 suggested, worked for me. I implemented this:

    override fun hashCode() : Int = id.toString().hashCode()
    

    My Kotlin compiler setting in AndroidStudio is :

    • incremental compilation enabled
    • target JVM ver. 1.6

提交回复
热议问题