No Creators, like default construct, exist): cannot deserialize from Object value (no delegate- or property-based Creator) in Kotlin mit Jackson und Retrofit
Hallo zusammen! Ich bin neu in Kotlin und Android-Entwicklung. Ich schreibe eine App, die Daten vom Server über Retrofit und Jackson abruft. Ich habe eine Data-Klasse für die API-Antwort:
```kotlin
data class UserResponse(
val id: Int,
val name: String,
val email: String
)
```
Und ein Retrofit-Interface:
```kotlin
interface ApiService {
@GET("users/{id}")
suspend fun getUser(@Path("id") userId: Int): UserResponse
}
```
In der `MainActivity` führe ich die Anfrage aus:
```kotlin
lifecycleScope.launch {
val response = apiService.getUser(1)
textView.text = response.name
}
```
Aber die App stürzt mit folgendem Fehler ab:
```
com.fasterxml.jackson.databind.exc.InvalidDefinitionException:
Cannot construct instance of `com.example.app.UserResponse`
(no Creators, like default co
Noch keine Antworten.
Anmelden um eine Antwort zu hinterlassen