AnimatedNavHost "java.lang.ClassCastException: java.util.ArrayList cannot be cast to java.util.Set"



我有一个单一的活动应用程序与不同的屏幕表示的可组合。我正在使用导航组件来处理屏幕导航。

我的导航组件AnimatedNavHost为:

val navController = rememberAnimatedNavController()
AnimatedNavHost(
navController = navController,
startDestination = Constants.SPLASH
) {
composable(Constants.SPLASH) {
Splash(navController = navController)
}

在运行应用程序时,我得到以下错误:

java.lang.ClassCastException: java.util.ArrayList cannot be cast to java.util.Set
at com.google.accompanist.navigation.animation.AnimatedNavHostKt.AnimatedNavHost$lambda-3(AnimatedNavHost.kt:323)
at com.google.accompanist.navigation.animation.AnimatedNavHostKt.AnimatedNavHost(AnimatedNavHost.kt:158)
at com.google.accompanist.navigation.animation.AnimatedNavHostKt.AnimatedNavHost(AnimatedNavHost.kt:85)

但代码工作正常使用'NavHost'而不是'AnimatedNavHost'

我的伴奏导航依赖项是:

implementation "com.google.accompanist:accompanist-navigation-animation:0.16.1"

我的Kotlin编译器扩展版本是:

kotlinCompilerExtensionVersion '1.0.2'
我的Kotlin版本是:
'1.5.21'

几个小时以来我一直在寻找解决方案,但没能找到。请帮我解决这个问题。非常感谢!

你的伴奏版本已经过时了。请确保您使用的是最新版本,即0.20.0

相关内容

最新更新