android – Can't get the correct gson response kitkat devices-ThrowExceptions

Exception or error:

I have problem to get the json response in 4.42. Actually am using Volley and Gson for taking the Web api. I got the correct response in my Lollipop, Marshmallow and kitkat 4.3. But in the case kitkat 4.4.2 and below versions I got the error. My Log cat is:

04-22 18:25:48.893 4799-4799/graffititechnologies.teachertalk E/IMGSRV: :0: PVRDRMOpen: TP3, ret = 50
04-22 18:25:48.893 4799-4799/graffititechnologies.teachertalk E/IMGSRV: :0: PVRDRMOpen: TP3, ret = 53
04-22 18:25:48.893 4799-4799/graffititechnologies.teachertalk E/IMGSRV: :0: PVRDRMOpen: TP3, ret = 54
04-22 18:25:48.893 4799-4799/graffititechnologies.teachertalk E/IMGSRV: :0: PVRDRMOpen: TP3, ret = 54
04-22 18:25:48.893 4799-4799/graffititechnologies.teachertalk E/IMGSRV: :0: PVRDRMOpen: TP3, ret = 54
04-22 18:25:48.903 4799-4799/graffititechnologies.teachertalk E/IMGSRV: :0: PVRDRMOpen: TP3, ret = 56
04-22 18:26:01.243 4799-4799/graffititechnologies.teachertalk E/Url is: >>>>>>>>> http://www.graffititechnologies.com/teacher_talk/index.php/user/user_login
04-22 18:26:01.343 4799-4817/graffititechnologies.teachertalk E/parameters: >>>>>>>>> {password=1, username=swaroop}
04-22 18:26:01.443 4799-4799/graffititechnologies.teachertalk E/Verification_response..: <HTML><HEAD>
     <meta http-equiv=pragma content=nocache>
     <META HTTP-EQUIV=Expires CONTENT=-1>
     <SCRIPT>
        location.href="http://10.10.4.254:8090/httpclient.html?u=http://www.graffititechnologies.com/teacher_talk/index.php/user/user_login"
     </SCRIPT>
     </HEAD><BODY>
     </BODY>
     </HTML>
04-22 18:26:01.463 4799-4799/graffititechnologies.teachertalk E/AndroidRuntime: FATAL EXCEPTION: main
    Process: graffititechnologies.teachertalk, PID: 4799
    com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: 

Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $
    at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:187)
    at com.google.gson.Gson.fromJson(Gson.java:805)
    at com.google.gson.Gson.fromJson(Gson.java:770)
    at com.google.gson.Gson.fromJson(Gson.java:719)
    at com.google.gson.Gson.fromJson(Gson.java:691)
    at graffititechnologies.teachertalk.modules.login.LoginActivity$1.onResponse(LoginActivity.java:92)
    at graffititechnologies.teachertalk.modules.login.LoginActivity$1.onResponse(LoginActivity.java:85)
    at com.android.volley.toolbox.StringRequest.deliverResponse(StringRequest.java:60)
    at com.android.volley.toolbox.StringRequest.deliverResponse(StringRequest.java:30)
    at com.android.volley.ExecutorDelivery$ResponseDeliveryRunnable.run(ExecutorDelivery.java:99)
    at android.os.Handler.handleCallback(Handler.java:733)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:149)
    at android.app.ActivityThread.main(ActivityThread.java:5061)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:515)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:787)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:603)
    at dalvik.system.NativeStart.main(Native Method)
 Caused by: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $
    at com.google.gson.stream.JsonReader.beginObject(JsonReader.java:387)
    at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:176)
    at com.google.gson.Gson.fromJson(Gson.java:805) 
    at com.google.gson.Gson.fromJson(Gson.java:770) 
    at com.google.gson.Gson.fromJson(Gson.java:719) 
    at com.google.gson.Gson.fromJson(Gson.java:691) 
    at graffititechnologies.teachertalk.modules.login.LoginActivity$1.onResponse(LoginActivity.java:92) 
    at graffititechnologies.teachertalk.modules.login.LoginActivity$1.onResponse(LoginActivity.java:85) 
    at com.android.volley.toolbox.StringRequest.deliverResponse(StringRequest.java:60) 
    at com.android.volley.toolbox.StringRequest.deliverResponse(StringRequest.java:30) 
    at com.android.volley.ExecutorDelivery$ResponseDeliveryRunnable.run(ExecutorDelivery.java:99) 
    at android.os.Handler.handleCallback(Handler.java:733) 
    at android.os.Handler.dispatchMessage(Handler.java:95) 
    at android.os.Looper.loop(Looper.java:149) 
    at android.app.ActivityThread.main(ActivityThread.java:5061) 
    at java.lang.reflect.Method.invokeNative(Native Method) 
    at java.lang.reflect.Method.invoke(Method.java:515) 
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:787) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:603) 
    at dalvik.system.NativeStart.main(Native Method) 

04-22 18:31:01.923 9526-9526/graffititechnologies.teachertalk E/IMGSRV: :0: PVRDRMOpen: TP3, ret = 50
04-22 18:31:01.923 9526-9526/graffititechnologies.teachertalk E/IMGSRV: :0: PVRDRMOpen: TP3, ret = 53
04-22 18:31:01.923 9526-9526/graffititechnologies.teachertalk E/IMGSRV: :0: PVRDRMOpen: TP3, ret = 54
04-22 18:31:01.923 9526-9526/graffititechnologies.teachertalk E/IMGSRV: :0: PVRDRMOpen: TP3, ret = 54
04-22 18:31:01.923 9526-9526/graffititechnologies.teachertalk E/IMGSRV: :0: PVRDRMOpen: TP3, ret = 54
04-22 18:31:01.933 9526-9526/graffititechnologies.teachertalk E/IMGSRV: :0: PVRDRMOpen: TP3, ret = 56
How to solve:

Leave a Reply

Your email address will not be published. Required fields are marked *