`java.lang.NoSuchMethodError: No static method set...
# compose
d
java.lang.NoSuchMethodError: No static method setContent(Landroid/app/Activity;Lkotlin/jvm/functions/Function0;)Landroidx/compose/Composition; in class Landroidx/ui/core/WrapperKt; or its super classes
Does anyone have any idea why this happens when calling setContent { }? I have tried: • 0.1.0-dev05, dev06 and dev07 • Kotlin 1.3.61 and 1.3.70 • with and without buildFeatures { compose true } and/or composeOptions
l
the signature it is looking for
Copy code
setContent(Landroid/app/Activity;Lkotlin/jvm/functions/Function0;)Landroidx/compose/Composition
Is the signature that the kotlin compiler would normally look for. With our plugin, however, it should instead be looking for:
Copy code
setContent(Landroid/app/Activity;Lkotlin/jvm/functions/Function1;)Landroidx/compose/Composition
This exists and will be found. The fact that you’re looking for the wrong one suggests one of: 1. you are running the kotlin compiler on your code without our plugin 2. you are running the kotlin compiler on your code with an older version of our plugin Can you send me your build.gradle?
d
@Leland Richardson [G] https://pastebin.com/9hKYnJbZ And
Copy code
ext {
    kotlinVersion = '1.3.61'
    jetpackComposeVersion = "0.1.0-dev07"
    reaktiveVersion = "1.1.10"
    ktorVersion = "1.3.1"
    coroutinesVersion = "1.3.3-native-mt"
    klockVersion = "1.8.4"
    serializationVersion = "0.14.0"
//also tried kotlin 1.3.70 + serialization 0.20.0 in case it was something related to this - no luck
    multidexVersion = '2.0.1'
}
It's the same thing when I play with different versions of Kotlin/Compose, removing androidx.compose:compose-runtime/compiler from dependencies etc, I think I've tried every possible combination
s
Copy code
android {

    ...
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}
d
@Samuel Michael What about it? No difference with or without that block
l
based on the gpaste, i don’t see anything that sticks out as missing…. but there might be something related to your project being a multi-platform project. IIUC the AGP plugin and kotlin MPP seem to have a lot of conflicts
d
Ah okay, thanks for the info. So basically I'm f***ed 🙄
l
i wouldn’t go that far. AGP isn’t actually doing much w.r.t. compose. You can add a few kotlin compiler arguments and it would basically be done i think. I’m trying to find out if anyone else has done this though and if they did what they put in their gradle file to fix it
d
@Leland Richardson [G] I would be immensely grateful if you would find out anything. It seems like I combed through a better part of the internet in search of any kind of hint
l
I can’t find someone who has done this successfully. let me see if i can lead you in the right direction though. The kotlin compiler needs a few arguments passed to it in order to work for compose. AGP does this normally, but i’m not sure it is succeeding with the MPP plugin. You can see a few places where we do this in the compose repo ourselves. basically, you want to add 3 arguments to kotlinc. You can do this in gradle similar to: 1)
Copy code
project.tasks.withType(KotlinCompile::class.java).configureEach { compile ->
            compile.kotlinOptions.freeCompilerArgs +=
                listOf("-P", "plugin:androidx.compose.plugins.idea:enabled=true")
2)
Copy code
compile.kotlinOptions.freeCompilerArgs +=
   "-Xplugin=${/* path to compose compiler plugin jar */}"
3)
Copy code
compile.kotlinOptions.freeCompilerArgs += "-Xuse-ir"
It might take some finessing to get right but that’s about the size of it
d
@Leland Richardson [G] I think combination of these args helped (?) - or definitely did something - because now I'm getting a different error and the build fails. Do you think there could also be a clash between Compose/AGP/MPP and Serialization plugin or maybe something else is going on here?
java.lang.AssertionError: org.jetbrains.kotlinx.serialization.compiler.extensions.SerializationResolveExtension caused LinkageError
Caused by: java.lang.NoSuchMethodError: org.jetbrains.kotlin.descriptors.impl.TypeParameterDescriptorImpl.createWithDefaultBound(Lorg/jetbrains/kotlin/descriptors/DeclarationDescriptor;Lorg/jetbrains/kotlin/descriptors/annotations/Annotations;ZLorg/jetbrains/kotlin/types/Variance;Lorg/jetbrains/kotlin/name/Name;ILorg/jetbrains/kotlin/storage/StorageManager;)
l
hmm. i’m not sure what is happening here. it could be that the version of the kotlin compiler and the version of the serialization plugin are mismatched?
u
I tried this both in MPP and standalone Android project, as soon as I add a serialization plugin the build fails with the following exception
Copy code
e: java.lang.AbstractMethodError: org.jetbrains.kotlinx.serialization.compiler.extensions.SerializationLoweringExtension.generate(Lorg/jetbrains/kotlin/ir/declarations/IrFile;Lorg/jetbrains/kotlin/backend/common/BackendContext;Lorg/jetbrains/kotlin/resolve/BindingContext;)V
        at org.jetbrains.kotlin.backend.jvm.JvmBackendFacade.doGenerateFilesInternal$backend_jvm(JvmBackendFacade.kt:86)
        at org.jetbrains.kotlin.backend.jvm.JvmBackendFacade.doGenerateFilesInternal$backend_jvm$default(JvmBackendFacade.kt:64)
        at org.jetbrains.kotlin.backend.jvm.JvmBackendFacade.doGenerateFilesInternal$backend_jvm(JvmBackendFacade.kt:52)
        at org.jetbrains.kotlin.backend.jvm.JvmIrCodegenFactory.generateModule(JvmIrCodegenFactory.kt:36)
        at org.jetbrains.kotlin.codegen.KotlinCodegenFacade.doGenerateFiles(KotlinCodegenFacade.java:47)
        at org.jetbrains.kotlin.codegen.KotlinCodegenFacade.compileCorrectFiles(KotlinCodegenFacade.java:39)
        at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.generate(KotlinToJVMBytecodeCompiler.kt:638)
        at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli(KotlinToJVMBytecodeCompiler.kt:198)
        at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:172)
        at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:56)
        at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:85)
        at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:43)
        at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:104)
        at org.jetbrains.kotlin.incremental.IncrementalJvmCompilerRunner.runCompiler(IncrementalJvmCompilerRunner.kt:349)
        at org.jetbrains.kotlin.incremental.IncrementalJvmCompilerRunner.runCompiler(IncrementalJvmCompilerRunner.kt:105)
        at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compileIncrementally(IncrementalCompilerRunner.kt:237)
        at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.access$compileIncrementally(IncrementalCompilerRunner.kt:37)
        at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner$compile$2.invoke(IncrementalCompilerRunner.kt:79)
        at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compile(IncrementalCompilerRunner.kt:91)
        at org.jetbrains.kotlin.daemon.CompileServiceImplBase.execIncrementalCompiler(CompileServiceImpl.kt:606)
        at org.jetbrains.kotlin.daemon.CompileServiceImplBase.access$execIncrementalCompiler(CompileServiceImpl.kt:99)
        at org.jetbrains.kotlin.daemon.CompileServiceImpl.compile(CompileServiceImpl.kt:1645)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:357)
        at sun.rmi.transport.Transport$1.run(Transport.java:200)
        at sun.rmi.transport.Transport$1.run(Transport.java:197)
        at java.security.AccessController.doPrivileged(Native Method)
        at sun.rmi.transport.Transport.serviceCall(Transport.java:196)
        at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:573)
        at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:834)
        at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:688)
        at java.security.AccessController.doPrivileged(Native Method)
        at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:687)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)
Seems that enabling IR is causing serialization plugin to fail, compose works fine if the serialization is removed.
l
Can you file a bug for this so we can track it? I don’t think i’ve seen this particular issue yet
u
Sure, I will, but since I doubt this is a jetpack compose bug, would it be better to file it with kotlinx serialization, or somehwere else?
l
i think it’s an issue with our kotlin configuration. My guess is this is something that will go away once we rebase, or is something that the kotlin team needs to know about anyway and we might be the right people to communicate it
u
👍
l
thanks
298 Views