question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Exception: Unsupported metadata type: kotlinx.metadata.jvm.KotlinClassMetadata$SyntheticClass

See original GitHub issue

Build fails with an exception from kapt processing step:

...
Caused by: org.jetbrains.kotlin.kapt3.base.util.KaptBaseError: Exception while annotation processing
        at org.jetbrains.kotlin.kapt3.base.AnnotationProcessingKt.doAnnotationProcessing(annotationProcessing.kt:83)
        at org.jetbrains.kotlin.kapt3.base.AnnotationProcessingKt.doAnnotationProcessing$default(annotationProcessing.kt:34)
        at org.jetbrains.kotlin.kapt3.base.Kapt.kapt(Kapt.kt:45)
        ... 28 more
Caused by: java.lang.IllegalStateException: Unsupported metadata type: kotlinx.metadata.jvm.KotlinClassMetadata$SyntheticClass@6928739
        at dagger.internal.codegen.kotlin.KotlinMetadata.metadataOf(KotlinMetadata.java:225)
        at dagger.internal.codegen.kotlin.KotlinMetadata.from(KotlinMetadata.java:196)
        at dagger.internal.codegen.kotlin.KotlinMetadataFactory.create(KotlinMetadataFactory.java:56)
        at dagger.internal.codegen.kotlin.KotlinMetadataUtil.isCompanionObjectClass(KotlinMetadataUtil.java:86)
        at dagger.internal.codegen.validation.BindingMethodValidator$MethodValidator.checkEnclosingElement(BindingMethodValidator.java:169)
        at dagger.internal.codegen.validation.BindingMethodValidator$MethodValidator.checkAdditionalProperties(BindingMethodValidator.java:151)
        at dagger.internal.codegen.validation.BindingElementValidator$ElementValidator.validate(BindingElementValidator.java:153)
        at dagger.internal.codegen.validation.BindingElementValidator$ElementValidator.access$000(BindingElementValidator.java:137)
        at dagger.internal.codegen.validation.BindingElementValidator.validateUncached(BindingElementValidator.java:86)
        at dagger.internal.codegen.base.Util.reentrantComputeIfAbsent(Util.java:33)
        at dagger.internal.codegen.validation.BindingElementValidator.validate(BindingElementValidator.java:82)
        at dagger.internal.codegen.validation.AnyBindingMethodValidator.validateUncached(AnyBindingMethodValidator.java:99)
        at dagger.internal.codegen.base.Util.reentrantComputeIfAbsent(Util.java:33)
        at dagger.internal.codegen.validation.AnyBindingMethodValidator.validate(AnyBindingMethodValidator.java:74)
        at dagger.internal.codegen.validation.BindingMethodProcessingStep.process(BindingMethodProcessingStep.java:58)
        at dagger.internal.codegen.validation.BindingMethodProcessingStep.process(BindingMethodProcessingStep.java:30)
        at dagger.internal.codegen.validation.TypeCheckingProcessingStep.lambda$process$0(TypeCheckingProcessingStep.java:51)
        at com.google.common.collect.RegularImmutableMap.forEach(RegularImmutableMap.java:185)
        at dagger.internal.codegen.validation.TypeCheckingProcessingStep.process(TypeCheckingProcessingStep.java:48)
        at dagger.internal.codegen.validation.TypeCheckingProcessingStep.process(TypeCheckin
...

Dagger version we use is 2.26.1, but the issue persists on 2.32. Kotlin version is 1.4.21

From the basic research I’ve done, it seems that Dagger still uses old org.jetbrains.kotlinx:kotlinx-metadata-jvm:0.1.0 library version, while 0.2.0 with some new API is released.

So the steps to fix this issue, as I see it, are:

  1. Bump the version in org.jetbrains.kotlinx:kotlinx-metadata-jvm to 0.2.0
  2. Support KotlinClassMetadata.SyntheticClass (and any other new metadata types) in dagger.internal.codegen.kotlin.KotlinMetadata and possibly adapt its use-sites.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:9
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
barry-dempseycommented, Apr 16, 2021

This issue looks to have been addressed in release 2.34

3reactions
danysantiagocommented, Feb 12, 2021

The trace shows the SyntheticClass had to be inspected while validating binding method @Provides, @Binds, @Producer, etc. SyntheticClass are generated for a few things but the most likely the case you are running into is a binding method ending on a synthetic class because its an interface default method.

Something like this would cause this:

@Module
interface MyModule {
  @Provides
  fun provide() = "Hello"
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Hilt Unsupported metadata version in Kotlin - Stack Overflow
IllegalStateException : Unsupported metadata version. Check that your Kotlin version is >= 1.0 at dagger.internal.codegen.kotlin.KotlinMetadata.metadataOf( ...
Read more >
Unsupported metadata version" in KaptWithoutKotlincTask ...
This is a dagger issue. Daggers uses old version of kotlinx-metadata-jvm library to parse kotlin metadata. It doesn't support kotlin version 1.5.x. They...
Read more >
Unsupported metadata version. Check that your Kotlin version ...
Unsupported metadata version. Check that your Kotlin version is >= 1.0: java.lang.IllegalStateException: Unsupported metadata version.
Read more >
src/main/java/com/android/tools/r8/kotlin ... - Google Git
InconsistentKotlinMetadataException ;. import kotlinx.metadata.jvm.KotlinClassHeader; ... DexAnnotationElement kind = elementMap.get(kotlin.metadata.kind);.
Read more >
Announcing kotlinx-metadata-jvm library for reading/modifying ...
Please welcome a new library kotlinx-metadata-jvm designed for tools that need to read or modify the Kotlin metadata, such as bytecode ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found