Hi, I encountered Compose Multiplatform (Jetbrains...
# compose
d
Hi, I encountered Compose Multiplatform (Jetbrains) Navigation crash with the following stack trace Compose Multiplatform version 1.7.1 with navigation 2.8.0-alpha10 which is based on Jetpack Navigation 2.8 Did anyone maybe experience something similar?
Copy code
Fatal Exception: java.lang.IndexOutOfBoundsException: Index -1 out of bounds for length 1
       at jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64)
       at jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:70)
       at jdk.internal.util.Preconditions.checkIndex(Preconditions.java:266)
       at java.util.Objects.checkIndex(Objects.java:359)
       at java.util.ArrayList.get(ArrayList.java:434)
       at androidx.navigation.compose.NavHostKt$NavHost$25$1.invokeSuspend(NavHost.kt:518)
       at androidx.navigation.compose.NavHostKt$NavHost$25$1.invoke(NavHost.kt:8)
       at androidx.navigation.compose.NavHostKt$NavHost$25$1.invoke(NavHost.kt:4)
       at androidx.activity.compose.OnBackInstance$job$1.invokeSuspend(PredictiveBackHandler.kt:121)
       at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
       at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:101)
       at androidx.compose.ui.platform.AndroidUiDispatcher.performTrampolineDispatch(AndroidUiDispatcher.android.kt:81)
       at androidx.compose.ui.platform.AndroidUiDispatcher.access$setScheduledFrameDispatch$p(AndroidUiDispatcher.android.kt)
       at androidx.compose.ui.platform.AndroidUiDispatcher.access$performTrampolineDispatch(AndroidUiDispatcher.android.kt)
       at androidx.compose.ui.platform.AndroidUiDispatcher$dispatchCallback$1.run(AndroidUiDispatcher.android.kt:57)
       at android.os.Handler.handleCallback(Handler.java:958)
       at android.os.Handler.dispatchMessage(Handler.java:99)
       at android.os.Looper.loopOnce(Looper.java:230)
       at android.os.Looper.loop(Looper.java:319)
       at android.app.ActivityThread.main(ActivityThread.java:9063)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:588)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1103)
i
Already fixed. Will be available in the next alpha
Oh, nope. It's Android, so it's different one
Sorry for confusion
d
Yeah, this is Android… Let me know if you need some additional info to report this issue if it doesn’t exist already
i
We use original Google's binary for Android, so it's better to look though Google issue tracker directly
d
ok thanks! btw do you know when will the new alpha be out approx? and which version of Jetpack Compose Navigation will be based on?
i
Soon (c) 😅 Speaking without jokes - we're planning to do the next release together with Compose 1.8.0-alpha. Hope this week, but we had some CI refactor, so things can be delayed. It will be still based on 2.8.0 this time (most likely)
d
ok thanks a lot! 🙂
s
https://issuetracker.google.com/issues/375343407 https://issuetracker.google.com/issues/340202286 It's probably these issues. I am not even sure if this is fixed yet actually, since it has had a couple of cycles of being marked as fixed but it still showed up in a different form later.
d
It looks like this could be the case https://issuetracker.google.com/issues/375343407 Probably version 2.8.5 will show if it’s really fixed… Thanks for the info!
s
Just note that 2.8.5 will be released earliest 11th of December, because that's when the next release cycle is scheduled for androidx.
d
Yeah, so probably it will come to Compose Multiplatform some time next year, early hopefully 😅
👍 1
i
btw Android can be updated independently - just add newer Google dependency in androidMain. It's better to use this only for patches to keep things compatible
d
@Ivan Matkov It’s nice that you mention that. Is that kind of general guideline: for Android keep major and minor versions the same as stated in Compose Multiplatform base dependency and use Jetpack dependencies for newest fixes?
i
With current approach where we redirect to original Google binaries - yes. It works for Compose, lifecycle and navigation. I'd avoid calling it "general guideline", because things are based on some hacks and might be changed in future. I mean, we do not plan to start re-publishing Android or so, but I have to add this note to avoid extra expectations.
d
Ok, I understand. Thanks for the clarification 🙂
s
How does it work if the later android version introduces new apis not available in the common dependency? Is it simply that you won't have access to those in commonMain but will have access in androidMain? And you rely on the fact that androidx has strict API guarantees so that things will for sure be compatible even when using the "old" apis from common? And does this guarantee potentially break at runtime if the apis used in common happen to have been experimental apis which may have changed in a backwards incompatible way?
i
Is it simply that you won't have access to those in commonMain but will have access in androidMain?
yes
And you rely on the fact that androidx has strict API guarantees so that things will for sure be compatible even when using the "old" apis from common?
yes. that's why I recommend to do it only for patches. There are couple of experimental APIs that WILL break between minor versions
And does this guarantee potentially break at runtime if the apis used in common happen to have been experimental apis which may have changed in a backwards incompatible way?
Most likely it will be compile time error
thank you color 1
👍 2
d
I can confirm that Android compose navigation 2.8.5 fixed the issue. Thanks again guys!
👍 1