private class WeatherTask extends AsyncTask<String , Void, Weather>{
@Override
protected Weather doInBackground(String... params) {
String data=((new WeatherHttpClient()).getWeatherData(params[0]));
weather = JSONWeatherParser.getWeather(data);
Log.v("Data:",weather.currentCondition.getDescreption());
return weather;
}
I am new to android development can somebody help me how to solve this exception error occurred during running the app
FATAL EXCEPTION: AsyncTask #1
Process: com.example.elangocandy.weatherapp, PID: 2764
java.lang.RuntimeException: An error occurred while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:309)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354)
at java.util.concurrent.FutureTask.setException(FutureTask.java:223)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
Caused by: java.lang.ClassCastException: com.android.okhttp.internal.huc
Caused by: java.lang.ClassCastException: com.android.okhttp.internal.hucClassCastException is thrown when you are trying to cast an object in to a type that is not actually in. I think the
WeatherHttpClientis a class written by you. So if you are doing a class casting inside this class you should do ainstance ofcheck before the casting.I can provide more details if you can post the body of the
WeatherHttpClientclass.Are you using volley library to do the network call?