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
72 stars 66 forks source link

Get Data from the Internet #19

Closed cuxxie closed 1 year ago

cuxxie commented 1 year 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

In which task and step of the codelab can this issue be found? Step 8, in the sample code to add JsonConverterFactory.

Describe the problem You converting to mediatype by using the toMediaType() String extension. But the toMediaType() string extension is introduced in OkHttp4 and your retrofit is still depending on OkHttp3 which cause missing string extension toMediaType(). You need to call MediaType.get("application/json") instead of using the extension method

Steps to reproduce?

  1. Follow the Codelab until step 8
  2. Follow the codelab step 8 until task: Update MarsApiService and MarsViewModel
  3. Follow the task until task step number 4
  4. Implement according to the sample code

Versions Android Studio version: 2021.3.1 Patch 1 API version of the emulator: N/A

Additional information

Screenshot 2022-11-27 165645

cuxxie commented 1 year ago

duplicate