NoSuchMethodError: java.lang.Long.hashCode

前端 未结 4 2104
暗喜
暗喜 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条回答
  •  Happy的楠姐
    2020-12-15 18:53

    I've encountered the same issue and the solution for me is to assign both compileOptions and kotlinOptions in build.gradle to version 1.8

    android {
      ...
      // Configure only for each module that uses Java 8
      // language features (either in its source code or
      // through dependencies).
      compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
      }
      // For Kotlin projects
      kotlinOptions {
        jvmTarget = "1.8"
      }
    }
    

    Referenced from Use Java 8 language features of Android Developers official website.

提交回复
热议问题