Ich versuche, Parse.com Server abzufragen, aber ich habe einige Probleme mit Konverter, die ich nicht einmal verwenden und diesen Fehler erhalten: java.lang.IllegalArgumentException: Unable to create converter for class my-app-package/City
. Fehle ich hier etwas? Retrofit-Dokumentation ist nicht so leicht zu verdauen, wie ich möchte:Parse.com + Retrofit = "Kann Konverter für Klasse City nicht erstellen"
Berufung Klasse:
String BASE_URL = "https://api.parse.com/1/";
Retrofit retrofit = new Retrofit.Builder()
.baseUrl(BASE_URL)
.build();
EndpointApi service = retrofit.create(EndpointApi.class);
Call<City> call = service.getCityList(); //here is error
call.enqueue(new Callback<City>() {
@Override
public void onResponse(Call<City> call, Response<City> response) {
Log.i("asd", response.toString());
}
@Override
public void onFailure(Call<City> call, Throwable t) {
}
});
EndpointApi.class:
public interface EndpointApi {
@Headers({"X-Parse-Application-Id: ...",
"X-Parse-Client-Key: " + Constants.PARSE_CLIENT_KEY})
@POST("functions/listaMiastGps")
Call<City> getCityList();
}
City.class:
@ParseClassName(Constants.CITY_CLASS)
public class City extends ParseObject {
public City() {
}
public double getLat() {
return this.getParseGeoPoint("geo").getLatitude();
}
public double getLng() {
return this.getParseGeoPoint("geo").getLongitude();
}
public String getName(){
return this.getString("city");
}
}
JSON string Ich muss Daten lesen von:
{
"result": [
{
"ACL": {
"*": {
"read": true
}
},
"__type": "Object",
"city": "Kraków",
"className": "Cities",
"createdAt": "2016-07-08T10:44:30.191Z",
"geo": {
"__type": "GeoPoint",
"latitude": 50.0617021,
"longitude": 19.9370549
},
"objectId": "FHpUIN2kX0",
"updatedAt": "2016-07-08T10:47:18.561Z"
},
{
"ACL": {
"*": {
"read": true
}
},
"__type": "Object",
"city": "Warszawa",
"className": "Cities",
"createdAt": "2016-07-08T10:45:04.219Z",
"geo": {
"__type": "GeoPoint",
"latitude": 52.2329379,
"longitude": 21.0611941
},
"objectId": "SrfxmqsuAS",
"updatedAt": "2016-07-08T10:46:57.098Z"
},
{
"ACL": {
"*": {
"read": true
}
},
"__type": "Object",
"city": "Wrocław",
"className": "Cities",
"createdAt": "2016-07-08T10:45:13.980Z",
"geo": {
"__type": "GeoPoint",
"latitude": 51.1100065,
"longitude": 17.0325047
},
"objectId": "Mj0KRPWQgd",
"updatedAt": "2016-07-08T10:47:20.465Z"
},
{
"ACL": {
"*": {
"read": true
}
},
"__type": "Object",
"city": "Słupsk",
"className": "Cities",
"createdAt": "2016-07-08T14:11:38.488Z",
"geo": {
"__type": "GeoPoint",
"latitude": 54.4606811,
"longitude": 16.9580958
},
"objectId": "9HkXFmuS8a",
"updatedAt": "2016-07-08T14:12:44.083Z"
},
{
"ACL": {
"*": {
"read": true
}
},
"__type": "Object",
"city": "Gdańsk",
"className": "Cities",
"createdAt": "2016-07-09T20:44:38.173Z",
"geo": {
"__type": "GeoPoint",
"latitude": 54.3612063,
"longitude": 18.5499435
},
"objectId": "OhbqXGzd5v",
"updatedAt": "2016-07-09T20:44:51.491Z"
}
]
}
Danke, es hat funktioniert! Jetzt muss ich lernen, wie man Daten daraus liest. Ich habe meine Frage aktualisiert - wenn Sie so nett wären, einen Blick darauf zu werfen, wäre ich dankbar. –