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

NoSuchMethodError when running KSP2 with Dagger (KSP 2.0.0-1.0.21) #1911

Closed
lwasyl opened this issue May 22, 2024 · 1 comment
Closed

NoSuchMethodError when running KSP2 with Dagger (KSP 2.0.0-1.0.21) #1911

lwasyl opened this issue May 22, 2024 · 1 comment
Assignees
Labels
bug Something isn't working P1 major features or blocking bugs

Comments

@lwasyl
Copy link

lwasyl commented May 22, 2024

Dagger fails with java.lang.NoSuchMethodError: 'com.google.common.collect.ImmutableBiMap com.google.common.collect.ImmutableBiMap$Builder.buildOrThrow()'. The method was added in Guava 31

I see in project dependencies that Dagger correctly depends on Guava>31 and nothing seems to be overriding that version:

kspKotlinProcessorClasspath
+--- project :dependencies-platform
|    +--- org.junit:junit-bom:5.10.2
|    +--- org.jetbrains.kotlinx:kotlinx-coroutines-bom:1.8.1
|    +--- com.google.firebase:firebase-bom:33.0.0
|    +--- com.squareup.okhttp3:okhttp-bom:4.12.0
|    +--- androidx.compose:compose-bom:2024.05.00
|    +--- org.jetbrains.kotlin:kotlin-bom:2.0.0
|    |    +--- org.jetbrains.kotlin:kotlin-stdlib:2.0.0 (c)
|    |    +--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:2.0.0 (c)
|    |    +--- org.jetbrains.kotlin:kotlin-reflect:2.0.0 (c)
|    |    \--- org.jetbrains.kotlin:kotlin-stdlib-jdk7:2.0.0 (c)
|    +--- com.google.dagger:dagger-compiler:2.51.1 (c)
|    +--- com.google.dagger:dagger:2.51.1 (c)
|    \--- javax.inject:javax.inject:1 (c)
\--- com.google.dagger:dagger-compiler -> 2.51.1
     +--- com.google.dagger:dagger:2.51.1
     |    \--- javax.inject:javax.inject:1
     +--- com.google.dagger:dagger-spi:2.51.1
     |    +--- com.google.dagger:dagger:2.51.1 (*)
     |    +--- com.google.code.findbugs:jsr305:3.0.2
     |    +--- com.google.devtools.ksp:symbol-processing-api:1.9.20-1.0.14
     |    |    \--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.9.0 -> 2.0.0
     |    |         +--- org.jetbrains.kotlin:kotlin-stdlib:2.0.0
     |    |         |    +--- org.jetbrains:annotations:13.0
     |    |         |    +--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.0 -> 2.0.0 (c)
     |    |         |    \--- org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.8.0 -> 2.0.0 (c)
     |    |         \--- org.jetbrains.kotlin:kotlin-stdlib-jdk7:2.0.0
     |    |              \--- org.jetbrains.kotlin:kotlin-stdlib:2.0.0 (*)
     |    +--- com.google.guava:failureaccess:1.0.2
     |    +--- com.google.guava:guava:33.0.0-jre
     |    |    +--- com.google.guava:failureaccess:1.0.2
     |    |    +--- com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava
     |    |    +--- com.google.code.findbugs:jsr305:3.0.2
     |    |    +--- org.checkerframework:checker-qual:3.41.0
     |    |    \--- com.google.errorprone:error_prone_annotations:2.23.0
     |    +--- com.squareup:javapoet:1.13.0
     |    \--- javax.inject:javax.inject:1
     +--- com.google.code.findbugs:jsr305:3.0.2
     +--- com.google.devtools.ksp:symbol-processing-api:1.9.20-1.0.14 (*)
     +--- com.google.googlejavaformat:google-java-format:1.5
     |    +--- com.google.guava:guava:22.0 -> 33.0.0-jre (*)
     |    \--- com.google.errorprone:javac-shaded:9-dev-r4023-3
     +--- com.google.guava:failureaccess:1.0.2
     +--- com.google.guava:guava:33.0.0-jre (*)
     +--- com.squareup:javapoet:1.13.0
     +--- com.squareup:kotlinpoet:1.11.0
     |    +--- org.jetbrains.kotlin:kotlin-reflect:1.6.10 -> 2.0.0
     |    |    \--- org.jetbrains.kotlin:kotlin-stdlib:2.0.0 (*)
     |    \--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.10 -> 2.0.0 (*)
     +--- javax.inject:javax.inject:1
     +--- net.ltgt.gradle.incap:incap:0.2
     +--- org.checkerframework:checker-compat-qual:2.5.5
     \--- org.jetbrains.kotlin:kotlin-stdlib:1.9.20 -> 2.0.0 (*)

Stacktrace:

2: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':<project>:kspKotlin'.
> A failure occurred while executing com.google.devtools.ksp.gradle.KspAAWorkerAction
   > 'com.google.common.collect.ImmutableBiMap com.google.common.collect.ImmutableBiMap$Builder.buildOrThrow()'

* Try:
> Run with --info or --debug option to get more log output.
> Get more help at https://help.gradle.org.

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':<project>:kspKotlin'.
        at (lots of Gradle stacktrace)
Caused by: org.gradle.workers.internal.DefaultWorkerExecutor$WorkExecutionException: A failure occurred while executing com.google.devtools.ksp.gradle.KspAAWorkerAction
        at org.gradle.workers.internal.DefaultWorkerExecutor$WorkItemExecution.waitForCompletion(DefaultWorkerExecutor.java:287)
        at org.gradle.internal.work.DefaultAsyncWorkTracker.lambda$waitForItemsAndGatherFailures$2(DefaultAsyncWorkTracker.java:130)
        (again lots of Gradle stacktrace)
Caused by: java.lang.NoSuchMethodError: 'com.google.common.collect.ImmutableBiMap com.google.common.collect.ImmutableBiMap$Builder.buildOrThrow()'
        at dagger.internal.codegen.binding.ComponentDescriptor$Factory.createUncached(ComponentDescriptor.java:524)
        at dagger.internal.codegen.binding.ComponentDescriptor$Factory.lambda$create$0(ComponentDescriptor.java:446)
        at dagger.internal.codegen.base.Util.reentrantComputeIfAbsent(Util.java:33)
        at dagger.internal.codegen.binding.ComponentDescriptor$Factory.create(ComponentDescriptor.java:445)
        at dagger.internal.codegen.binding.ComponentDescriptor$Factory.rootComponentDescriptor(ComponentDescriptor.java:422)
        at dagger.internal.codegen.processingstep.ComponentProcessingStep.processRootComponent(ComponentProcessingStep.java:102)
        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:185)
        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:59)
        at dagger.spi.internal.shaded.androidx.room.compiler.processing.CommonProcessorDelegate.processRound(XBasicAnnotationProcessor.kt:132)
        at dagger.spi.internal.shaded.androidx.room.compiler.processing.ksp.KspBasicAnnotationProcessor.process(KspBasicAnnotationProcessor.kt:62)
        at com.google.devtools.ksp.impl.KotlinSymbolProcessing.execute(KotlinSymbolProcessing.kt:531)
        at com.google.devtools.ksp.impl.KSPLoader$Companion.loadAndRunKSP(KSPLoader.kt:36)
        at com.google.devtools.ksp.impl.KSPLoader.loadAndRunKSP(KSPLoader.kt)
        at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
        at java.base/java.lang.reflect.Method.invoke(Method.java:580)
        at com.google.devtools.ksp.gradle.KspAAWorkerAction.execute(KspAATask.kt:523)
        at org.gradle.workers.internal.DefaultWorkerServer.execute(DefaultWorkerServer.java:63)
        at org.gradle.workers.internal.NoIsolationWorkerFactory$1$1.create(NoIsolationWorkerFactory.java:66)
        at org.gradle.workers.internal.NoIsolationWorkerFactory$1$1.create(NoIsolationWorkerFactory.java:62)
        at org.gradle.internal.classloader.ClassLoaderUtils.executeInClassloader(ClassLoaderUtils.java:100)
        at org.gradle.workers.internal.NoIsolationWorkerFactory$1.lambda$execute$0(NoIsolationWorkerFactory.java:62)
        (... Gradle stuff)
@ting-yuan ting-yuan self-assigned this May 22, 2024
@ting-yuan ting-yuan added bug Something isn't working P1 major features or blocking bugs labels May 22, 2024
@ting-yuan
Copy link
Collaborator

KSP indirectly depends on Guava and bundled Guava 29.0 in its artifacts, and pollutes the classpath. As a short term fix, the Guava version is updated to 33.2.0. in KSP.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working P1 major features or blocking bugs
Projects
None yet
Development

No branches or pull requests

2 participants