URL of codelab:
Update MarsApiService and MarsViewModel
I followed every step from start, when i dowloaded the starter code everything is working fine, till the last step "In the getMarsPhotos() method, listResult is a List and not a String anymore. The size of that list is the number of photos that were received and parsed.
To print the number of photos retrieved, update marsUiState as follows:
val listResult = MarsApi.retrofitService.getPhotos()
marsUiState = MarsUiState.Success(
"Success: ${listResult.size} Mars photos retrieved"
)" it gives me error so i did like this private fun getMarsPhotos() {
viewModelScope.launch {
marsUiState = try {
val listResult = MarsApi.retrofitService.getPhotos()
MarsUiState.Success(
"Success: ${listResult.size} Mars photos retrieved")
} catch (e: IOException) {
MarsUiState.Error
}
}
}
Versions
_Android Studio version:_Android Studio Ladybug Feature Drop | 2024.2.2 Patch 1
API version of the emulator: API 34
Additional information
Include screenshots if they would be useful in clarifying the problem.
App crashed on start and i get this error, and by the way solution code is a lot different than starter code + this lessons

URL of codelab:
Update MarsApiService and MarsViewModel
I followed every step from start, when i dowloaded the starter code everything is working fine, till the last step "In the getMarsPhotos() method, listResult is a List and not a String anymore. The size of that list is the number of photos that were received and parsed.
To print the number of photos retrieved, update marsUiState as follows:
val listResult = MarsApi.retrofitService.getPhotos()
marsUiState = MarsUiState.Success(
"Success: ${listResult.size} Mars photos retrieved"
)" it gives me error so i did like this private fun getMarsPhotos() {
viewModelScope.launch {
marsUiState = try {
val listResult = MarsApi.retrofitService.getPhotos()
MarsUiState.Success(
"Success: ${listResult.size} Mars photos retrieved")
} catch (e: IOException) {
MarsUiState.Error
}
}
}
Versions
_Android Studio version:_Android Studio Ladybug Feature Drop | 2024.2.2 Patch 1
API version of the emulator: API 34
Additional information
Include screenshots if they would be useful in clarifying the problem.
App crashed on start and i get this error, and by the way solution code is a lot different than starter code + this lessons