-
Notifications
You must be signed in to change notification settings - Fork 67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Get Data from the Internet #150
Comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
URL of codelab:
https://developer.android.com/codelabs/basic-android-kotlin-compose-getting-data-internet?authuser=2&continue=https%3A%2F%2Fdeveloper.android.com%2Fcourses%2Fpathways%2Fandroid-basics-compose-unit-5-pathway-1%3Fauthuser%3D2%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?
In the Android Basic with compose > Connect to the internet > Get data > Get data from the internet template .
Describe the problem
I found that when i was implementing this following function
private val retrofit = Retrofit.Builder()
.addConverterFactory(Json.asConverterFactory("application/json".toMediaType()))
.baseUrl(BASE_URL)
.build()
and after that when i run my app then it crashes without opening . so, i go to logcat and ask that error with gemni ai then it says that Retrofit is unable to create a converter for the List type returned by the MarsApiService.getPhotos() method.
then it sugget to use
import retrofit2.converter.gson.GsonConverterFactory
private val retrofit = Retrofit.Builder()
.addConverterFactory(GsonConverterFactory.create())
.baseUrl(BASE_URL)
.build()
before this in the dependencies of gradle build module add
implementation("com.squareup.retrofit2:converter-gson:2.11.0")
after doing this now it works properly
Steps to reproduce?
Versions
Android Studio version: Android Studio Jellyfish
API version of the emulator: API Level 34
Additional information
Include screenshots if they would be useful in clarifying the problem.
The text was updated successfully, but these errors were encountered: