Hi guys just noticed something weird with compose ...
# compose
a
Hi guys just noticed something weird with compose navigation. My app crashes when i add 13
composables
in the
NavHost
have you noticed this as well? it works fine with 12 or less
Copy code
java.lang.ArrayIndexOutOfBoundsException: length=13; index=13
😄 1
1
Copy code
java.lang.ArrayIndexOutOfBoundsException: length=13; index=13
        at androidx.collection.SparseArrayCompat.valueAt(SparseArrayCompat.java:379)
        at androidx.navigation.NavController.setGraph(NavController.kt:898)
        at androidx.navigation.NavController.setGraph(NavController.kt:90)
        at androidx.navigation.compose.NavHostKt$NavHost$4.invoke(NavHost.kt:112)
        at androidx.navigation.compose.NavHostKt$NavHost$4.invoke(NavHost.kt:112)
        at androidx.compose.runtime.CompositionImpl$RememberEventDispatcher.dispatchSideEffects(Composition.kt:789)
        at androidx.compose.runtime.CompositionImpl.applyChanges(Composition.kt:640)
        at androidx.compose.runtime.Recomposer$runRecomposeAndApplyChanges$2$2.invoke(Recomposer.kt:479)
        at androidx.compose.runtime.Recomposer$runRecomposeAndApplyChanges$2$2.invoke(Recomposer.kt:416)
        at androidx.compose.ui.platform.AndroidUiFrameClock$withFrameNanos$2$callback$1.doFrame(AndroidUiFrameClock.android.kt:34)
        at androidx.compose.ui.platform.AndroidUiDispatcher.performFrameDispatch(AndroidUiDispatcher.android.kt:109)
        at androidx.compose.ui.platform.AndroidUiDispatcher.access$performFrameDispatch(AndroidUiDispatcher.android.kt:41)
        at androidx.compose.ui.platform.AndroidUiDispatcher$dispatchCallback$1.doFrame(AndroidUiDispatcher.android.kt:69)
        at android.view.Choreographer$CallbackRecord.run(Choreographer.java:970)
        at android.view.Choreographer.doCallbacks(Choreographer.java:796)
        at android.view.Choreographer.doFrame(Choreographer.java:727)
        at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:957)
        at android.os.Handler.handleCallback(Handler.java:938)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:223)
        at android.app.ActivityThread.main(ActivityThread.java:7656)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
p
You're probably doing smth wrong, I have more than 13 composables and it works fine
u
I’ll raise an issue to increase the limit to 14 😉
j
@Alexa_Gal Did you manage to find a fix for this? For some reason it crashes at me too with the exact same issue where I have 13 composables. I "solved" it by now by adding an empty 14th composable like this:
Copy code
composable("stub"){}
Wonder what the real cause is though 🤔
p
It happened for me after updating from
2.4.0-alpha04
to
2.4.0-alpha06
. Looks like there’s opened issue: https://issuetracker.google.com/issues/195171984
👍 1
j
Thanks, indeed noticed that it started after updating. Weird to see it happening at such specific values