URL of codelab:
https://developer.android.com/codelabs/basic-android-kotlin-compose-getting-data-internet?continue=https%3A%2F%2Fdeveloper.android.com%2Fcourses%2Fpathways%2Fandroid-basics-compose-unit-5-pathway-1%23codelab-https%3A%2F%2Fdeveloper.android.com%2Fcodelabs%2Fbasic-android-kotlin-compose-getting-data-internet#7
Specify the language of the codelab if it is not English:
English
In which task and step of the codelab can this issue be found?
Task: 8. Parse the JSON response with kotlinx.serialization
Step: Add kotlinx.serialization library dependencies
Describe the problem
Using id("org.jetbrains.kotlin.plugin.serialization") version "1.8.10" in the plugins block causes a surprising failure when launching the app on a device. Apparently you need to use a version greater than 2.0 (I got 2.1.0 to actually work) or else you get an error like the following when you try to launch the app:
Caused by: kotlinx.serialization.SerializationException: Serializer for class 'MarsPhoto' is not found.
Please ensure that class is marked as '@Serializable' and that the serialization compiler plugin is applied.
at kotlinx.serialization.internal.PlatformKt.serializerNotRegistered(Platform.kt:36)
at kotlinx.serialization.SerializersKt__SerializersJvmKt.serializer(SerializersJvm.kt:77)
at kotlinx.serialization.SerializersKt.serializer(Unknown Source:1)
at kotlinx.serialization.SerializersKt__SerializersJvmKt.serializerByJavaTypeImpl$SerializersKt__SerializersJvmKt(SerializersJvm.kt:113)
at kotlinx.serialization.SerializersKt__SerializersJvmKt.serializer(SerializersJvm.kt:76)
at kotlinx.serialization.SerializersKt.serializer(Unknown Source:1)
at retrofit2.converter.kotlinx.serialization.Serializer.serializer(Serializer.kt:22)
at retrofit2.converter.kotlinx.serialization.Factory.responseBodyConverter(Factory.kt:26)
at retrofit2.Retrofit.nextResponseBodyConverter(Retrofit.java:418)
at retrofit2.Retrofit.responseBodyConverter(Retrofit.java:401)
at retrofit2.HttpServiceMethod.createResponseConverter(HttpServiceMethod.java:137)
... 169 more
Steps to reproduce?
- Follow the codelab up until the task specified above. Follow all of the instructions as written.
- At the end of task 8, attempt to launch the app on a device.
- Watch the app immediately crash, and check the logs to see the stack trace listed above.
Versions
Android Studio version:
API version of the emulator:
Additional information
Include screenshots if they would be useful in clarifying the problem.
URL of codelab:
https://developer.android.com/codelabs/basic-android-kotlin-compose-getting-data-internet?continue=https%3A%2F%2Fdeveloper.android.com%2Fcourses%2Fpathways%2Fandroid-basics-compose-unit-5-pathway-1%23codelab-https%3A%2F%2Fdeveloper.android.com%2Fcodelabs%2Fbasic-android-kotlin-compose-getting-data-internet#7
Specify the language of the codelab if it is not English:
English
In which task and step of the codelab can this issue be found?
Task: 8. Parse the JSON response with kotlinx.serialization
Step: Add kotlinx.serialization library dependencies
Describe the problem
Using
id("org.jetbrains.kotlin.plugin.serialization") version "1.8.10"in the plugins block causes a surprising failure when launching the app on a device. Apparently you need to use a version greater than 2.0 (I got 2.1.0 to actually work) or else you get an error like the following when you try to launch the app:Steps to reproduce?
Versions
Android Studio version:
API version of the emulator:
Additional information
Include screenshots if they would be useful in clarifying the problem.