I have a project that uses moshi and I'm trying to...
# compose
c
I have a project that uses moshi and I'm trying to enable compose. So far I updated kotlin to 1.4, agp to 4.2.0-alpha10, gradle to 6.6.1, When I do the above, my app runs fine, it's only when I add
Copy code
buildFeatures {
    compose true
}
composeOptions {
    kotlinCompilerExtensionVersion MyVersions.compose_version //this id defined as val compose_version = "1.0.0-alpha02"
    kotlinCompilerVersion '1.4.0'
}
I get an error when my app runs due to moshi/kotlin reflection?
Copy code
E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.myapp.free, PID: 8768
    kotlin.reflect.jvm.internal.KotlinReflectionInternalError: Could not compute caller for function: public constructor MyNetworkResponse(myFields...) defined in com.myapp.free.MyNetworkResponse[DeserializedClassConstructorDescriptor@aa293b] (member = null)
        at kotlin.reflect.jvm.internal.KFunctionImpl$caller$2.invoke(KFunctionImpl.kt:89)
        at kotlin.reflect.jvm.internal.KFunctionImpl$caller$2.invoke(KFunctionImpl.kt:36)
        at kotlin.reflect.jvm.internal.ReflectProperties$LazyVal.invoke(ReflectProperties.java:62)
        at kotlin.reflect.jvm.internal.ReflectProperties$Val.getValue(ReflectProperties.java:31)
        at kotlin.reflect.jvm.internal.KFunctionImpl.getCaller(Unknown Source:7)
        at kotlin.reflect.jvm.ReflectJvmMapping.getJavaMethod(ReflectJvmMapping.kt:63)
        at kotlin.reflect.jvm.KCallablesJvm.setAccessible(KCallablesJvm.kt:82)
        at com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterFactory.create(KotlinJsonAdapter.kt:223)
        at com.squareup.moshi.Moshi.nextAdapter(Moshi.java:172)
Has anyone come across this? I've looked in issuetracker to no avail.
b
I ran into some issues using Kotlin Serialization because of Compose. I put the Kotlin Serialization stuff in a separate module and that fixed it for me. So maybe a similar approach could work for you 🤔
😭 1
c
That does not sound fun. Did you run across any bug reports or anything I can star/thumbs up?
b
Well in my case the build would just keep going on forever, really frustrating lol
I only had to put the data classes that used the
@Serializable
annotation in that module
e
Is this the latest moshi (
1.10.0
)?
c
@efemoney yes, I upgraded to latest moshi as it looked like the root of the issue was from there.