Exception: Unsupported metadata type: kotlinx.metadata.jvm.KotlinClassMetadata$SyntheticClass
See original GitHub issueBuild 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:
- Bump the version in
org.jetbrains.kotlinx:kotlinx-metadata-jvm
to0.2.0
- Support
KotlinClassMetadata.SyntheticClass
(and any other new metadata types) indagger.internal.codegen.kotlin.KotlinMetadata
and possibly adapt its use-sites.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:9
- Comments:6 (1 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This issue looks to have been addressed in release 2.34
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: