You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In which task and step of the codelab can this issue be found?
Step 8 - Parse the JSON response with kotlinx.serialization
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()
`
The above code snippet no longer successfully makes a working app on Android Studio, on either emulator or actual testing device.
Steps to reproduce?
Follow Codelab until Step 8
Try to run app
Error along the lines of:
Explain: FATAL EXCEPTION: main Process: com.example.marsphotos, PID: 23147 java.lang.IllegalArgumentException: Unable to create converter for java.util.List<com.example. marsphotos. network. MarsPhoto> for method MarsApiService.getPhotos at retrofit2.Utils.methodError( Utils. java: 54) with tag AndroidRuntime
Versions Android Studio version: Current version: Android Studio Koala | 2024.1.1 Patch 1 Al-241.18034.62.2411.12071903 July 11, 2024 API version of the emulator: 24 Nougat
Additional information Include screenshots if they would be useful in clarifying the problem.
The text was updated successfully, but these errors were encountered:
arnavpraneet
changed the title
Get Data from the Internet
JsonConvertor outdated, version 2+ requires different code than given in the codelab.
Sep 8, 2024
By comparing the end codelab code with the Github solution code, the fix for this was to bump the plugin version of 'org.jetbrains.kotlin.plugin.serialization' from 1.8.10 up to 1.9.10.
As mentioned though, the codelab needs updating to include this.
URL of codelab:
Codelab
In which task and step of the codelab can this issue be found?
Step 8 - Parse the JSON response with kotlinx.serialization
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()
`
The above code snippet no longer successfully makes a working app on Android Studio, on either emulator or actual testing device.
Steps to reproduce?
Versions
Android Studio version: Current version: Android Studio Koala | 2024.1.1 Patch 1 Al-241.18034.62.2411.12071903 July 11, 2024
API version of the emulator: 24 Nougat
Potential Solution
This StackOverflow link: https://stackoverflow.com/questions/34315499/unable-to-create-converter-for-java-util-list-retrofit-2-0-0-beta2 gives the correct code in the first answer:
String baseUrl = "" ; Retrofit client = new Retrofit.Builder() .baseUrl(baseUrl) .addConverterFactory(GsonConverterFactory.create()) .build();
Additional information
Include screenshots if they would be useful in clarifying the problem.
The text was updated successfully, but these errors were encountered: