google-developer-training / basic-android-kotlin-compose-training-mars-photos

Solution code for Android Basics in Kotlin course
https://developer.android.com/courses/android-basics-kotlin/course?gclid=CjwKCAjw4c-ZBhAEEiwAZ105RTyT-iaLHzrhMBUXdMhO230ZDwOwxxI2x4RgK8DwBxK8t1h0wmU_QxoCi4YQAvD_BwE
Apache License 2.0
66 stars 54 forks source link

Get Data from the Internet #109

Open orjanhsy opened 5 months ago

orjanhsy commented 5 months ago

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:

In which task and step of the codelab can this issue be found?

  1. Parse the JSON response with kotlinx.serialization

Describe the problem In the section: "Add kotlinx.serialization library dependencies", you are told to put this:

id("org.jetbrains.kotlin.plugin.serialization") version "1.8.10"

FATAL EXCEPTION: main Process: com.example.marsphotos, PID: 25719 java.lang.IllegalArgumentException: Unable to create converter for java.util.List for method MarsApiService.getPhotos

-In order to fix this, I checked your solution files and discovered you are really using:

id("org.jetbrains.kotlin.plugin.serialization") version "1.9.10"

Steps to reproduce?

  1. Go to the solution files -> build.gradle.kts (module :app)
  2. Change the plugin: id("org.jetbrains.kotlin.plugin.serialization") version "1.9.10" - (which is the version in your solution files) to version 1.8.10 (which is what you are asking in the "Get data from the internet" codelab, section 8.
  3. Run the app and see the runtime error

Versions Android Studio version: Android Studio Hedgehog | 2023.1.1 Patch 1 API version of the emulator: 33/34 (both crash)

Additional information Include screenshots if they would be useful in clarifying the problem.

NemesisJWD commented 4 months ago

Had the same issue. Setting the plugin: id("org.jetbrains.kotlin.plugin.serialization") version from "1.8.10" to "1.9.10" solved the issue.

Additionally you might want to set: implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.0") instead of :1.5.1.