Describe the problem
When following the instructions in the codelab, the app doesn't run. It terminates instantly with the following exception.
FATAL EXCEPTION: main
Process: com.example.marsphotos, PID: 18673
java.lang.IllegalArgumentException: Unable to create converter for java.util.List<com.example.marsphotos.model.MarsPhoto>
for method MarsApiService.getPhotos
at retrofit2.Utils.methodError(Utils.java:54)
...
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:31)
...
Comparing with the solution code, one can see that the instructions in the codelab use different versions for the serialization plugin and for the json serialization import.
The codelab has:
id("org.jetbrains.kotlin.plugin.serialization") version "1.8.10"
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.1")
while the solution code has (in repo-starter):
id("org.jetbrains.kotlin.plugin.serialization") version "1.9.10"
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.0")
Somehow, updating the versions fixes the problem.
Steps to reproduce
Follow the codelab, use version 1.8.10 for the serialization plugin and 1.5.1 for the json serialization import
Run the app
See error in log cat
Change plugin version to 1.9.10 for the serialization plugin and 1.6.0 for the json serialization import
Run the app
App works fine
VersionsAndroid Studio version: Build #AI-241.14494.240.2411.11700778, built on April 11, 2024
API version of the emulator: 34
URL of codelab: https://developer.android.com/codelabs/basic-android-kotlin-compose-getting-data-internet
Specify the language of the codelab if it is not English: It's English.
In which task and step of the codelab can this issue be found? 8. Parse the JSON response with kotlinx.serialization
Describe the problem When following the instructions in the codelab, the app doesn't run. It terminates instantly with the following exception.
Comparing with the solution code, one can see that the instructions in the codelab use different versions for the serialization plugin and for the json serialization import.
The codelab has:
while the solution code has (in repo-starter):
Somehow, updating the versions fixes the problem.
Steps to reproduce
Versions Android Studio version: Build #AI-241.14494.240.2411.11700778, built on April 11, 2024 API version of the emulator: 34