I am trying to pass a test instance of one of my d...
# compose
j
I am trying to pass a test instance of one of my data classes into one of my composables in a preview and I’m getting
java.lang.NoClassDefFoundError: Could not initialize class...
whenever I try to create the data class instance within my preview composable function. Has anyone else run into this before?
The code is essentially like this:
Copy code
@Preview("preview")
@Composable
fun Preview() {
   val data = SomeDataClass(field1 = "value", field2 = "value")
   MyScreenComposable(data = data)
}
This throws a NoClassDefFoundError within the Preview Error pane. It compiles fine through Gradle.
The NoClassDefFoundError is saying it can’t find “SomeDataClass”
a
I think clean build will fix this issue
j
I tried that and still had the issue. I ended up just refactoring my composable so I could just pass primitives to it instead of the entire data class instance