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 58 forks source link

Get Data from the Internet #14

Closed MasiarNovine closed 1 year ago

MasiarNovine commented 1 year ago

URL of codelab:

Get data from the internet

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

In Parse the JSON response with kotlinx.serialization under Update MarsApiService and MarsViewModel.

Describe the problem

Steps to reproduce?

  1. Go to the second code snippet under Update MarsApiService and MarsViewModel.
  2. Try to initialize the variable retrofit: The method toMediaType() used for conversion of the string value is not known, when using the given import statement.

Possible solution

Change the import statement in the code snippet of the codelab to import okhttp3.Companion.toMediaType and update the modules build.gradle with a newer version of OkHttp, e.g. by including implementation "com.squareup.okhttp3:okhttp:4.10.0".

Versions

MasiarNovine commented 1 year ago

Duplicate of #10 and others, but might still be useful due to the possible solution given.

osuleymanova commented 1 year ago

Hello @MasiarNovine,

Thank you for reaching out to us and reporting this issue. The code block is updated:

Screenshot 2023-01-04 at 8 46 32 AM