voyager icon indicating copy to clipboard operation
voyager copied to clipboard

Kotlin JS - IrLinkageError - Function 'Navigator' can not be called: No function found for symbol

Open romainbsl opened this issue 1 year ago • 4 comments

Hello, I am trying to work with Voyager on a Compose Web project, but I am getting an issue at runtime.

"Function 'Navigator' can not be called: No function found for symbol 
'cafe.adriel.voyager.navigator/Navigator|Navigator(cafe.adriel.voyager.core.screen.Screen;cafe.adriel.voyager.navigator.NavigatorDisposeBehavior?;kotlin.Function1<cafe.adriel.voyager.core.screen.Screen,kotlin.Boolean>?;kotlin.String?;kotlin.Function3<cafe.adriel.voyager.navigator.Navigator,androidx.compose.runtime.Composer,kotlin.Int,kotlin.Unit>?;androidx.compose.runtime.Composer?;kotlin.Int;kotlin.Int){}[0]'"

Here is my gradle.build.kts:

plugins {
    alias(libs.plugins.kotlinMultiplatform)
    alias(libs.plugins.jetbrainsCompose)
}

kotlin {
    js(IR) {
        browser()
        binaries.executable()
    }

    sourceSets {
        jsMain.dependencies {
            implementation(kotlin.compose.html.core)
            implementation(kotlin.compose.runtimeSaveable)
            implementation(libs.voyager.navigator)
        }
    }
}

compose.experimental {
    web.application {}
}

And my main.kt file:

import androidx.compose.runtime.Composable
import cafe.adriel.voyager.core.screen.Screen
import cafe.adriel.voyager.navigator.Navigator
import org.jetbrains.compose.web.dom.H1
import org.jetbrains.compose.web.dom.Text
import org.jetbrains.compose.web.renderComposableInBody

fun main() {
    renderComposableInBody {
//        H1 { Text("Voyager Test App") }
        Navigator(HomeScreen)
    }
}

object HomeScreen : Screen {
    @Composable
    override fun Content() {
        H1 { Text("Voyager Test App") }
    }
}

Here is a reproducer based on a https://kmp.jetbrains.com template.

I checked your sample project multiplatform, that works, but was getting the same issue by copy / pasting your code inside my project. Not sure of what's going on here.

romainbsl avatar Jan 21 '24 14:01 romainbsl

The reason is: the voyager have to use the compose multiplatform version 1.6.0-beta01 or higher

terrakok avatar Feb 02 '24 13:02 terrakok

Hi I have the same issue, but using 1.6.0-rc02 Compose Multiplatform version. Works great with Android, Desktop targets, but getting the same error on Web.

Project: https://github.com/HLCaptain/butler/tree/64d0413de58ea3c91d3827bdfceea38a18ac1853

HLCaptain avatar Feb 17 '24 17:02 HLCaptain

Same here, it's not working on Compose Multiplatform v1.6.0-rc02

ismai117 avatar Feb 19 '24 08:02 ismai117

Same here v1.6.0-rc03

maqsats avatar Feb 19 '24 16:02 maqsats

@DevSrSouza Please can you help us with this?

maqsats avatar Feb 20 '24 11:02 maqsats

Should be fixed on https://github.com/adrielcafe/voyager/releases/tag/1.1.0-alpha03

We have update Compose KMP and add WASM support.

DevSrSouza avatar Feb 23 '24 13:02 DevSrSouza

https://github.com/JetBrains/compose-multiplatform/issues/4361 still cannot build

maqsats avatar Feb 24 '24 11:02 maqsats

Just getting back at my sample project and it works.

Here is the toml updated:

[versions]
jbCompose = "1.6.0"
kotlin = "1.9.22"
voyager = "1.1.0-alpha03"

[libraries]
voyager-navigator = { module = "cafe.adriel.voyager:voyager-navigator", version.ref = "voyager" }

[plugins]
jetbrainsCompose = { id = "org.jetbrains.compose", version.ref = "jbCompose" }
kotlinMultiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }

Thanks for the work on voyager!

romainbsl avatar Mar 01 '24 14:03 romainbsl