survivingwithandroid / WeatherLib

Android Weather Library: android weather lib to develop weather based app fast and easily
http://survivingwithandroid.github.io/WeatherLib/
640 stars 170 forks source link

JSONException error #14

Closed g123k closed 10 years ago

g123k commented 10 years ago

Hi,

I'm using your fantastic lib with Okhttp & OpenStreetMap. I'm trying to get the current condition in Paris (id = 2988507), but it fails with this logcat :

07-24 15:46:01.515 1974-1986/com.easycell.daydream W/System.err﹕ org.json.JSONException: End of input at character 0 of 07-24 15:46:01.515 1974-1986/com.easycell.daydream W/System.err﹕ at org.json.JSONTokener.syntaxError(JSONTokener.java:450) 07-24 15:46:01.515 1974-1986/com.easycell.daydream W/System.err﹕ at org.json.JSONTokener.nextValue(JSONTokener.java:97) 07-24 15:46:01.515 1974-1986/com.easycell.daydream W/System.err﹕ at org.json.JSONObject.(JSONObject.java:154) 07-24 15:46:01.515 1974-1986/com.easycell.daydream W/System.err﹕ at org.json.JSONObject.(JSONObject.java:171) 07-24 15:46:01.515 1974-1986/com.easycell.daydream W/System.err﹕ at com.survivingwithandroid.weather.lib.provider.openweathermap.OpenweathermapProvider.getCurrentCondition(OpenweathermapProvider.java:85) 07-24 15:46:01.515 1974-1986/com.easycell.daydream W/System.err﹕ at com.survivingwithandroid.weather.lib.client.okhttp.WeatherDefaultClient$4.onResponse(WeatherDefaultClient.java:306) 07-24 15:46:01.515 1974-1986/com.easycell.daydream W/System.err﹕ at com.squareup.okhttp.Call$AsyncCall.execute(Call.java:150) 07-24 15:46:01.515 1974-1986/com.easycell.daydream W/System.err﹕ at com.squareup.okhttp.internal.NamedRunnable.run(NamedRunnable.java:33) 07-24 15:46:01.515 1974-1986/com.easycell.daydream W/System.err﹕ at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076) 07-24 15:46:01.515 1974-1986/com.easycell.daydream W/System.err﹕ at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569) 07-24 15:46:01.515 1974-1974/com.easycell.daydream W/System.err﹕ com.survivingwithandroid.weather.lib.exception.WeatherLibException: org.json.JSONException: End of input at character 0 of 07-24 15:46:01.515 1974-1974/com.easycell.daydream W/System.err﹕ at com.survivingwithandroid.weather.lib.provider.openweathermap.OpenweathermapProvider.getCurrentCondition(OpenweathermapProvider.java:167) 07-24 15:46:01.515 1974-1974/com.easycell.daydream W/System.err﹕ at com.survivingwithandroid.weather.lib.client.okhttp.WeatherDefaultClient$4.onResponse(WeatherDefaultClient.java:306) 07-24 15:46:01.515 1974-1974/com.easycell.daydream W/System.err﹕ at com.squareup.okhttp.Call$AsyncCall.execute(Call.java:150) 07-24 15:46:01.515 1974-1974/com.easycell.daydream W/System.err﹕ at com.squareup.okhttp.internal.NamedRunnable.run(NamedRunnable.java:33) 07-24 15:46:01.515 1974-1974/com.easycell.daydream W/System.err﹕ at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076) 07-24 15:46:01.515 1974-1974/com.easycell.daydream W/System.err﹕ at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569) 07-24 15:46:01.515 1974-1974/com.easycell.daydream W/System.err﹕ at java.lang.Thread.run(Thread.java:856) 07-24 15:46:01.515 1974-1974/com.easycell.daydream W/System.err﹕ Caused by: org.json.JSONException: End of input at character 0 of 07-24 15:46:01.515 1974-1974/com.easycell.daydream W/System.err﹕ at org.json.JSONTokener.syntaxError(JSONTokener.java:450) 07-24 15:46:01.515 1974-1974/com.easycell.daydream W/System.err﹕ at org.json.JSONTokener.nextValue(JSONTokener.java:97) 07-24 15:46:01.515 1974-1974/com.easycell.daydream W/System.err﹕ at org.json.JSONObject.(JSONObject.java:154) 07-24 15:46:01.515 1974-1974/com.easycell.daydream W/System.err﹕ at org.json.JSONObject.(JSONObject.java:171) 07-24 15:46:01.515 1974-1974/com.easycell.daydream W/System.err﹕ at com.survivingwithandroid.weather.lib.provider.openweathermap.OpenweathermapProvider.getCurrentCondition(OpenweathermapProvider.java:85) 07-24 15:46:01.515 1974-1974/com.easycell.daydream W/System.err﹕ ... 6 more 07-24 15:46:01.515 1974-1986/com.easycell.daydream W/System.err﹕ at java.lang.Thread.run(Thread.java:856)

Any solution?

survivingwithandroid commented 10 years ago

I'm checking the log and i will tell you the solution. Are you sure you get the JSON response from the server?

survivingwithandroid commented 10 years ago

I coded a sample app using the information you gave to me: OkHttpCient, Openweathermap and the id you told to me. It works! Give a look at this gist: https://gist.github.com/survivingwithandroid/d671961572899cb8f4b4

survivingwithandroid commented 10 years ago

Do you have more info about the problem? Did you solve it? Is it a lib bug? Let me know Thx

g123k commented 10 years ago

I think it was on the OpenStreetMap side, because everything is working fine now. I'm sorry for this.