sto solo facendo una richiesta GET, ma sto ottenendo questo errore:Impossibile creare convertitore per java.util.List retrofit 2.0.0-beta2
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.yomac_000.chargingpoint/com.example.yomac_000.chargingpoint.AllStores}: java.lang.IllegalArgumentException: Unable to create converter for java.util.List<model.Store>
Ed è a causa di questa linea di codice:
Call<List<Store>> call = subpriseAPI.listStores(response);
così mi aveva cercato con questa riga di codice per vedere che tipo è:
System.out.println(subpriseAPI.listStores(response).getClass().toString());
Ma poi ho ottenere lo stesso errore in modo che non le so di che tipo è. Qui sotto puoi vedere il mio codice.
StoreService.java:
public class StoreService {
public static final String BASE_URL = "http://getairport.com/subprise/";
Retrofit retrofit = new Retrofit.Builder()
.baseUrl(BASE_URL)
.build();
SubpriseAPI subpriseAPI = retrofit.create(SubpriseAPI.class);
String response = "";
public List<Store> getSubprises() {
Call<List<Store>> call = subpriseAPI.listStores(response);
try {
List<Store> listStores = call.execute().body();
System.out.println("liststore "+ listStores.iterator().next());
return listStores;
} catch (IOException e) {
// handle errors
}
return null;
}
}
SubpriseAPI.java:
public interface SubpriseAPI {
@GET("api/locations/get")
Call<List<Store>> listStores(@Path("store") String store);
}
Store.java:
public class Store {
String name;
}
Sto utilizzando la versione 2.0.0-beta2 retrofit.
Ho anche avuto questo problema e ho chiesto agli sviluppatori di retrofit a rendere l'errore più significativo qui https://github.com/square/retrofit/issues/1774. –