Hi all, I’m using `ApolloJsonParser.parseJsonRespo...
# apollo-kotlin
g
Hi all, I’m using
ApolloJsonParser.parseJsonResponse()
to create mock data from Json for Compose Previews and I’m getting this error. Has anyone experienced this? TIA
Copy code
java.lang.NoSuchFieldError: Companion
	at com.apollographql.apollo3.api.json.BufferedSourceJsonReader.<clinit>(BufferedSourceJsonReader.kt:855)
b
hmm it doesn't ring a bell, but looks like proguard/r8 issue? Which version of Apollo Kotlin are you on?
g
The app builds/works fine. This happens for Previews in Compose.
v3.8.1
I’ve seen this error being reported on Github and it was caused by version conflict between Okhttp I believe. But the problem here is that it works fine when you run the project but fails in the Preview window.
b
Oooh specific to previews hmmm. I just tried in the Apollo tutorial, and it seems to work for me (Apollo v3.8.2, Android Studio 2022.2.1 Flamingo). Are you doing something similar to this?
Copy code
@Preview
@Composable
private fun LaunchDetailsPreview() {
    LaunchDetails(
        LaunchDetailsQuery("42").parseJsonResponse("{some json}").data!!,
    )
}
g
Yes similar. Interesting
m
I've seen stuff like this, like here for an example
That was an old version of
okio
ApolloJsonParser
Can you double check this @goku? I don't think we have a
ApolloJsonParser
in 3.8.1
b
Not sure exactly how the classpath for Previews is assembled but I would look at
./gradlew :app:dependencies
and
./gradlew :app:buildEnvironment
to see what version(s) of Okio you may have - the one coming from Apollo should be 3.2.0.