Running with kotlin version '1.4.32' my Android project runs and builds. Trying to upgrade to kotlin '1.5.0' and my build throws:
Execution failed for task ':app:kaptDefaultsDebugKotlin'. > A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptWithoutKotlincTask$KaptExecutionWorkAction > java.lang.reflect.InvocationTargetException (no error message)
I am not even sure where to start looking. Anyone else have problems upgrading to kotlin 1.5.0?
The Android Kotlin compiler produces Java 8 bytecode by default (which runs in any later JVM), but lets the programmer choose to target Java 9 up to 18, for optimization, or allows for more features; has bidirectional record class interoperability support for JVM, introduced in Java 16, considered stable as of Kotlin ...
Select your module in the Project window, and then select File > New, select any Android template, and then choose Kotlin as the Source language.
I experienced the same issue today. Ran the gradle build command with --stacktrace
and got a helpful stacktrace which narrowed down the issue to Moshi library.
Caused by: java.lang.IllegalStateException: Could not parse metadata! This should only happen if you're using Kotlin <1.1. at com.squareup.moshi.kotlinpoet.metadata.KotlinPoetMetadata.readKotlinClassMetadata(KotlinPoetMetadata.kt:70) at com.squareup.moshi.kotlinpoet.metadata.KotlinPoetMetadata.toImmutableKmClass(KotlinPoetMetadata.kt:50) at com.squareup.moshi.kotlin.codegen.MoshiCachedClassInspector.toImmutableKmClass(MoshiCachedClassInspector.kt:22) at com.squareup.moshi.kotlin.codegen.MetadataKt.targetType(metadata.kt:109) at com.squareup.moshi.kotlin.codegen.JsonClassCodegenProcessor.adapterGenerator(JsonClassCodegenProcessor.kt:136) at com.squareup.moshi.kotlin.codegen.JsonClassCodegenProcessor.process(JsonClassCodegenProcessor.kt:110) at org.jetbrains.kotlin.kapt3.base.incremental.IncrementalProcessor.process(incrementalProcessors.kt:90) at org.jetbrains.kotlin.kapt3.base.ProcessorWrapper.process(annotationProcessing.kt:175) at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:980) ... 41 more
Had to update Moshi to 1.12.0
and that did the trick.
Here's a changelog for Moshi 1.12.0
that mentions the fix for 1.5.0: https://github.com/square/moshi/blob/master/CHANGELOG.md#version-1120
Issue when it was first reported here: https://github.com/square/moshi/issues/1324
Another issue which mentions the fix here: https://github.com/square/moshi/issues/1337
So I'd suggest you run gradle build command with --stacktrace
and figure out which library causes the incompatibility with the kotlinx-metadata-jvm
library and update it.
This is due to Dagger's use of older version of kotlinx-metadata-jvm
. See https://youtrack.jetbrains.com/issue/KT-45885
Update your dagger to 2.34
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