I have an error in my Kotlin project that I don't understand.
The project was working but then I clone it on another PC and on this other PC I have this error below:
FATAL EXCEPTION: main (Ask Gemini)
Process: sguichard.myapplication, PID: 16760
kotlin.NotImplementedError: Implemented only in JetBrains fork.
at androidx.navigation.compose.NavHostController_nonAndroidKt.rememberNavController(NavHostController.nonAndroid.kt:32)
at sguichard.myapplication.MainActivityKt.MainActivityContent(MainActivity.kt:69)
at sguichard.myapplication.ComposableSingletons$MainActivityKt$lambda-1$1.invoke(MainActivity.kt:58)
at sguichard.myapplication.ComposableSingletons$MainActivityKt$lambda-1$1.invoke(MainActivity.kt:57)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:109)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:35)
at androidx.compose.ui.platform.ComposeView.Content(ComposeView.android.kt:441)
at androidx.compose.ui.platform.AbstractComposeView$ensureCompositionCreated$1.invoke(ComposeView.android.kt:259)
at androidx.compose.ui.platform.AbstractComposeView$ensureCompositionCreated$1.invoke(ComposeView.android.kt:258)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:109)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:35)
at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:380)
at androidx.compose.ui.platform.CompositionLocalsKt.ProvideCommonCompositionLocals(CompositionLocals.kt:216)
at androidx.compose.ui.platform.AndroidCompositionLocals_androidKt$ProvideAndroidCompositionLocals$3.invoke(AndroidCompositionLocals.android.kt:132)
at androidx.compose.ui.platform.AndroidCompositionLocals_androidKt$ProvideAndroidCompositionLocals$3.invoke(AndroidCompositionLocals.android.kt:131)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:109)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:35)
at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:380)
at androidx.compose.ui.platform.AndroidCompositionLocals_androidKt.ProvideAndroidCompositionLocals(AndroidCompositionLocals.android.kt:121)
at androidx.compose.ui.platform.WrappedComposition$setContent$1$1$3.invoke(Wrapper.android.kt:155)
at androidx.compose.ui.platform.WrappedComposition$setContent$1$1$3.invoke(Wrapper.android.kt:154)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:109)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:35)
at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:401)
at androidx.compose.ui.platform.WrappedComposition$setContent$1$1.invoke(Wrapper.android.kt:154)
at androidx.compose.ui.platform.WrappedComposition$setContent$1$1.invoke(Wrapper.android.kt:133)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:109)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:35)
at androidx.compose.runtime.ActualJvm_jvmKt.invokeComposable(ActualJvm.jvm.kt:97)
at androidx.compose.runtime.ComposerImpl.doCompose(Composer.kt:3595)
at androidx.compose.runtime.ComposerImpl.composeContent$runtime_release(Composer.kt:3522)
at androidx.compose.runtime.CompositionImpl.composeContent(Composition.kt:743)
at androidx.compose.runtime.Recomposer.composeInitial$runtime_release(Recomposer.kt:1122)
at androidx.compose.runtime.CompositionImpl.composeInitial(Composition.kt:649)
at androidx.compose.runtime.CompositionImpl.setContent(Composition.kt:635)
at androidx.compose.ui.platform.WrappedComposition$setContent$1.invoke(Wrapper.android.kt:133)
at androidx.compose.ui.platform.WrappedComposition$setContent$1.invoke(Wrapper.android.kt:124)
at androidx.compose.ui.platform.AndroidComposeView.setOnViewTreeOwnersAvailable(AndroidComposeView.android.kt:1626)
at androidx.compose.ui.platform.WrappedComposition.setContent(Wrapper.android.kt:124)
2026-03-18 09:59:23.819 16760-16760 AndroidRuntime sguichard.myapplication E at androidx.compose.ui.platform.WrappedComposition.onStateChanged(Wrapper.android.kt:180) (Ask Gemini)
at androidx.lifecycle.LifecycleRegistry$ObserverWithState.dispatchEvent(LifecycleRegistry.jvm.kt:313)
at androidx.lifecycle.LifecycleRegistry.addObserver(LifecycleRegistry.jvm.kt:191)
at androidx.compose.ui.platform.WrappedComposition$setContent$1.invoke(Wrapper.android.kt:131)
at androidx.compose.ui.platform.WrappedComposition$setContent$1.invoke(Wrapper.android.kt:124)
at androidx.compose.ui.platform.AndroidComposeView.onAttachedToWindow(AndroidComposeView.android.kt:1707)
at android.view.View.dispatchAttachedToWindow(View.java:20753)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3490)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3497)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3497)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3497)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3497)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2613)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:2126)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:8653)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1037)
at android.view.Choreographer.doCallbacks(Choreographer.java:845)
at android.view.Choreographer.doFrame(Choreographer.java:780)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1022)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at android.app.ActivityThread.main(ActivityThread.java:7839)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
Here is the code of my MainActivity.kt (the rest is not important):
package sguichard.myapplication
import android.app.AlertDialog
import android.content.Context
import android.os.Bundle
import android.util.Log
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.CardColors
import androidx.compose.material3.ElevatedButton
import androidx.compose.material3.ElevatedCard
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.NavigationBar
import androidx.compose.material3.NavigationBarItem
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.material3.TopAppBar
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import androidx.navigation.compose.rememberNavController
import kotlinx.coroutines.launch
import sguichard.myapplication.api.CarShareAreaApiManager
import sguichard.myapplication.model.AllCarShareArea
import sguichard.myapplication.model.CarShareArea
import sguichard.myapplication.ui.theme.MyApplicationTheme
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
enableEdgeToEdge()
setContent {
MainActivityContent()
}
}
}
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun MainActivityContent(){
var currentPage by remember { mutableStateOf(NavigationKeys.PAGE_1) }
val context = LocalContext.current
var startDestination = NavigationKeys.PAGE_1
val navController = rememberNavController()
var selectedDestination by rememberSaveable{
mutableIntStateOf(startDestination.ordinal)
}
Scaffold(
modifier = Modifier.fillMaxSize(),
topBar = {
TopAppBar(
title = {
Text(
text = when(currentPage){
NavigationKeys.PAGE_1 -> NavigationKeys.PAGE_1.title
NavigationKeys.PAGE_2 -> NavigationKeys.PAGE_2.title
else -> ""
}
)
}
)
},
bottomBar = {
NavigationBar {
NavigationKeys.entries.forEach {
NavigationBarItem(
selected = selectedDestination == it.ordinal,
onClick = {
navController.navigate(route = it.name)
selectedDestination = it.ordinal
currentPage = it
},
icon = { Icon(it.icon, it.contentdescription) },
label = { Text(it.title) }
)
}
}
}
) { innerPadding ->
NavHost(
navController,
startDestination = startDestination.name
){
NavigationKeys.entries.forEach { destination -> composable (destination.name){
when (destination) {
NavigationKeys.PAGE_1 -> CarShareAreaScreen(
modifier = Modifier.padding(innerPadding)
)
NavigationKeys.PAGE_2 -> MapScreen()
else -> {}
}
}
}
}
}
}
@Composable
fun MapScreen(modifier: Modifier = Modifier){
Text("Map")
}
@Composable
fun CarShareAreaScreen(modifier: Modifier = Modifier) {
var allCarShareArea by remember { mutableStateOf<AllCarShareArea?>(null) }
val coroutineScope = rememberCoroutineScope()
LaunchedEffect(Unit){
coroutineScope.launch {
CarShareAreaApiManager.fetchCarShareArea()
.onSuccess { allCarShareArea = it }
.onFailure { Log.e("Api", "${it.message}") }
}
}
var context = LocalContext.current
Column (
modifier = modifier
.padding(25.dp)
.verticalScroll(rememberScrollState())
){
Text(
text = "Liste des Aires de Covoiturages"
)
allCarShareArea?.results?.forEach {
TextButton(
onClick = {detailsDialogCarShareArea(context, it)}
) {
ElevatedCard(
modifier = Modifier
.padding(10.dp, 5.dp)
.fillMaxSize(),
colors = CardColors(Color.DarkGray, Color.White, Color.DarkGray, Color.White)
) {
Row{
Column (
modifier = Modifier.weight(0.70f)
){
var modifierText = Modifier.padding(10.dp, 2.dp)
Text(text = "${it.name}", modifier = modifierText)
Text(text = "${it.town}", modifier = modifierText)
Text(text = "${it.places.let { it }?:"Non renseigné"}", modifier = modifierText)
}
ElevatedButton(
onClick = { TODO() },
modifier = Modifier.weight(0.30f)
.align(Alignment.CenterVertically)
.padding(10.dp, 0.dp)
) {
Image(
painter = painterResource(id = R.drawable.outline_map_24),
contentDescription = "Carte"
)
}
}
}
}
}
}
}
private fun detailsDialogCarShareArea(
context: Context,
carShareArea: CarShareArea
) {
val builder: AlertDialog.Builder = AlertDialog.Builder(context)
builder
.setTitle("Details")
.setMessage("${carShareArea.toString()}")
val dialog = builder.create()
dialog.show()
}
@Preview(showBackground = true)
@Composable
fun GreetingPreview() {
MyApplicationTheme {
CarShareAreaScreen()
}
}
I need to solve this error but I don't know how to do it, If someone ever face this error and/or know how to handle it, I would take the advice !
PS : This is a student project so it is normal if nothing is perfect, normally this was working