https://kotlinlang.org logo
Title
r

rsktash

12/08/2021, 3:03 AM
Hi I’m trying to integrate facebook ads network via Admob mediation to my app But I’ve encountered an error while restoring view state when using
AndroidView(factory: ..)
inside Compose LazyList As a workaround I checked duplicate ids and reset them to random id Error message: IllegalArgumentException: Wrong state class, expecting View State but received class… This usually happens when two views of different type have the same id in the same hierarchy.
a

Adam Powell

12/08/2021, 4:48 AM
You should be able to use
View.generateViewId()
and not rely on random
i

Ian Lake

12/08/2021, 5:59 AM
View.generateViewId()
isn't stable across configuration changes (it is just a static, ever increasing counter that never gives you the same number back), so if you actually want your state restored correctly, you can't use that either
a

Adam Powell

12/08/2021, 6:02 AM
Yeah you would need to persist it; in a rememberSaveable or similar you'd avoid collisions
☝️🏼 1
☝️ 3