voyager
voyager copied to clipboard
Crash when only using Material 3 with bottom sheet navigator
In my Compose Multiplatform project, I'm only using Material 3.
Today, I added Voyager bottom sheet navigator dependency and a set it up like in the documentation:
BottomSheetNavigator {
Navigator(screen = screen)
}
When I launch the app, here is the crash:
java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/compose/material/ModalBottomSheetDefaults;
at cafe.adriel.voyager.navigator.bottomSheet.BottomSheetNavigatorKt.BottomSheetNavigator-zm8iufA(BottomSheetNavigator.kt:43)
at ComposableSingletons$AppKt$lambda-2$1.invoke(App.kt:48)
at ComposableSingletons$AppKt$lambda-2$1.invoke(App.kt:45)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:116)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)
at androidx.compose.animation.CrossfadeKt$Crossfade$4$1.invoke(Crossfade.kt:115)
at androidx.compose.animation.CrossfadeKt$Crossfade$4$1.invoke(Crossfade.kt:110)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:107)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)
at androidx.compose.animation.CrossfadeKt.Crossfade(Crossfade.kt:124)
at androidx.compose.animation.CrossfadeKt.Crossfade(Crossfade.kt:55)
[...]
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [androidx.compose.runtime.PausableMonotonicFrameClock@e52dbc0, androidx.compose.ui.platform.MotionDurationScaleImpl@ebc40f9, StandaloneCoroutine{Cancelling}@b89b83e, AndroidUiDispatcher@dba869f]
Caused by: java.lang.ClassNotFoundException: Didn't find class "androidx.compose.material.ModalBottomSheetDefaults" on path: DexPathList[[zip file "/data/app/~~l4wx1La4M_x5U7ysAyKgCg==/com.ebfstudio.appgpt-V5dAepwEWSUZF9ggginaQA==/base.apk"],nativeLibraryDirectories=[/data/app/~~l4wx1La4M_x5U7ysAyKgCg==/com.ebfstudio.appgpt-V5dAepwEWSUZF9ggginaQA==/lib/arm64, /system/lib64, /system_ext/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:259)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
... 68 more
This is because the project do not include Material (but only material 3).
The workaround is to add implementation(compose.material)
.
Is it possible to use Voyager Bottom Sheets with only Material 3? If not, I suggest updating the documentation specifying that the Material dependency is required to make it work.
+1 same error
I don't think it is possible atm, because BottomSheetNavigator under the hood uses BottomSheetLayout from compose.material.
I do think the correct solution is to update BottomSheetNavigator so that it uses BottomSheetScaffold instead.
That said, someone has to put in the time and do it. 😁
We should have a copy of the current Bottom Sheet module but for Material 3. We don't have the time now to work on it, but we appreciate a PR.
After 1.0.0 I will create it
Small tip for the workaround in the meantime: you can use runtimeOnly(compose.material)
instead of implementation
in order to not pollute the imports with non-material3 composables.