I switched over my Android project from 1.3.20 to 1.3.30 and I am suddenly getting following exceptions from some of the classes when they call hashCode() method. Note, I am getting this exception only on Android platform API 21 & 22, beyond Android API 24, everything works fine.
Caused by: java.lang.NoSuchMethodError: No static method hashCode(J)I in class Ljava/lang/Long; or its super classes (declaration of 'java.lang.Long' appears in /system/framework/core-libart.jar)
There is this thread that mentions similar symptoms but that was for Kotlin 1.2, I am wondering if anybody is encountering similar situation and if there is a workaround for this?
In 1.3, we've completely reworked the model of multiplatform projects in order to improve expressiveness and flexibility, and to make sharing common code easier. Also, Kotlin/Native is now supported as one of the targets!
Update to a new release IntelliJ IDEA and Android Studio suggest updating to a new release once it is out. When you accept the suggestion, it automatically updates the Kotlin plugin to the new version. You can check the Kotlin version in Tools | Kotlin | Configure Kotlin Plugin Updates.
jetbrains. kotlin:kotlin-gradle-plugin:$kotlin_version" . So, change ext. kotlin_version to be the value that you want.
Kotlin 1.5 was released in May 2021. Kotlin 1.6 was released in November 2021. Kotlin 1.7 was released in June 2022, including the alpha version of the new Kotlin K2 compiler.
As an alternative, you may set a JVM target for Kotlin compilation to "1.6"
, as Kotlin 1.3.30 has started to infer the JVM target from the Java version in android.compileOptions
and chooses "1.8"
if both sourceCompatibility
and targetCompatibility
are set to that or higher.
In the module's build.gradle
, add:
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
kotlinOptions {
jvmTarget = '1.6'
}
}
There will be no need to do this once the issue in D8 desugaring is fixed.
This issue is tracked in the Kotlin issue tracker as KT-31027.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With