Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Kotlin 2.1.0 #4451

Closed
ZacSweers opened this issue Sep 23, 2024 · 5 comments
Closed

Support Kotlin 2.1.0 #4451

ZacSweers opened this issue Sep 23, 2024 · 5 comments

Comments

@ZacSweers
Copy link

ZacSweers commented Sep 23, 2024

When testing dagger with K2 Kapt on Kotlin 2.1.0-Beta1, it fails with the below trace.

Repro

Trace

Caused by: java.lang.IllegalStateException: Unable to read Kotlin metadata due to unsupported metadata version.	
	at dagger.internal.codegen.kotlin.KotlinMetadata.metadataOf(KotlinMetadata.java:180)	
	at dagger.internal.codegen.kotlin.KotlinMetadata.from(KotlinMetadata.java:157)	
	at dagger.internal.codegen.kotlin.KotlinMetadataFactory.create(KotlinMetadataFactory.java:55)	
	at dagger.internal.codegen.kotlin.KotlinMetadataUtil.getAllMethodNamesBySignature(KotlinMetadataUtil.java:89)	
	at dagger.internal.codegen.validation.ComponentValidator$ElementValidator.validateClassMethodName(ComponentValidator.java:256)	
	at dagger.internal.codegen.validation.ComponentValidator$ElementValidator.validateComponentMethods(ComponentValidator.java:247)	
	at dagger.internal.codegen.validation.ComponentValidator$ElementValidator.validateElement(ComponentValidator.java:176)	
	at dagger.internal.codegen.validation.ComponentValidator.validateUncached(ComponentValidator.java:136)	
	at dagger.internal.codegen.base.Util.reentrantComputeIfAbsent(Util.java:33)	
	at dagger.internal.codegen.validation.ComponentValidator.validate(ComponentValidator.java:132)	
	at dagger.internal.codegen.processingstep.ComponentProcessingStep.isComponentValid(ComponentProcessingStep.java:149)	
	at dagger.internal.codegen.processingstep.ComponentProcessingStep.processRootComponent(ComponentProcessingStep.java:98)	
	at dagger.internal.codegen.processingstep.ComponentProcessingStep.process(ComponentProcessingStep.java:87)	
	at dagger.internal.codegen.processingstep.ComponentProcessingStep.process(ComponentProcessingStep.java:49)	
	at dagger.internal.codegen.processingstep.TypeCheckingProcessingStep.lambda$process$0(TypeCheckingProcessingStep.java:94)	
	at com.google.common.collect.RegularImmutableMap.forEach(RegularImmutableMap.java:297)	
	at dagger.internal.codegen.processingstep.TypeCheckingProcessingStep.process(TypeCheckingProcessingStep.java:72)	
	at dagger.internal.codegen.processingstep.TypeCheckingProcessingStep.process(TypeCheckingProcessingStep.java:49)	
	at dagger.spi.internal.shaded.androidx.room.compiler.processing.XProcessingStep.process(XProcessingStep.kt:57)	
	at dagger.spi.internal.shaded.androidx.room.compiler.processing.CommonProcessorDelegate.processRound(XBasicAnnotationProcessor.kt:134)	
	at dagger.spi.internal.shaded.androidx.room.compiler.processing.javac.JavacBasicAnnotationProcessor.process(JavacBasicAnnotationProcessor.kt:75)	
	at org.jetbrains.kotlin.kapt3.base.incremental.IncrementalProcessor.process(incrementalProcessors.kt:90)
@bcorso
Copy link

bcorso commented Sep 23, 2024

I think this should have been fixed by #4211 (comment) but you'll need to use the HEAD-SNAPSHOTS until the next official release.

@ZacSweers
Copy link
Author

quick edit - not specific to K2 kapt, this is just a general need for an updated release with newer kotlin-metadata

@TWiStErRob
Copy link

TWiStErRob commented Nov 27, 2024

This became very relevant suddenly as Kotlin 2.1.0 is released.

We're on latest release (dagger = "2.52") and the error showed up in the Kotlin 2.1 Renovate PR.
Using dagger = "HEAD-SNAPSHOT" with

repositories {
    google()
    mavenCentral()
    exclusiveContent {
        forRepository {
            maven("https://oss.sonatype.org/content/repositories/snapshots") {
                name = "Sonatype SNAPSHOTs"
            }
        }
        filter {
            includeVersionByRegex("com\\.google\\.dagger.*", ".*", "HEAD-SNAPSHOT")
        }
    }
}

solves this issue, so this confirms Brad's claim above.

So we need a new Dagger/Hilt release to be able to use Kotlin 2.1.0.

@bcorso
Copy link

bcorso commented Nov 27, 2024

@TWiStErRob thanks for confirming. I'll be out the next few days, but I can do a release early next week.

@bcorso
Copy link

bcorso commented Dec 3, 2024

Closing. This should be fixed in Dagger 2.53.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants