Closed myhency closed 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
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?
Update MarsApiService and MarsViewModel
Describe the problem
import com.jakewharton.retrofit2.converter.kotlinx.serialization.asConverterFactory import kotlinx.serialization.json.Json import okhttp3.MediaType private val retrofit = Retrofit.Builder() .addConverterFactory(Json.asConverterFactory("application/json".toMediaType())) .baseUrl(BASE_URL) .build()
I have never applied okhttp to gradle in the course of this codelab. So I could see an error on toMediaType()
okhttp
toMediaType()
So in the before part Add kotlinx.serialization library dependencies here, it should be added the code below.
Add kotlinx.serialization library dependencies
implementation 'com.squareup.okhttp3:okhttp:4.10.0'
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.
Hello @myhency,
Thank you for reaching out to us and sharing your concern. The code block is updated:
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: It's English
In which task and step of the codelab can this issue be found?
Update MarsApiService and MarsViewModel
Describe the problem
I have never applied
okhttp
to gradle in the course of this codelab. So I could see an error ontoMediaType()
So in the before part
Add kotlinx.serialization library dependencies
here, it should be added the code below.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.