标题
volley.ParseError
com.android.volley.ParseError:
org.json.JSONException:Value indexModule of type java.lang.String connot be converted to JSONObject
服务器返回值不是json格式,而使用了JsonRequest。解决办法,检查后台返回json的合法性;不使用JsonRequest。
If you want to receive the result as a string don’t use the JSONRequest. Go with the simple Request class. Your problem is pretty simple the server is giving back a JSONArray with just one element inside. A JSONArray is not a JSONObject. That’s why the parsing is failing.
如果你想获得的结果作为一个字符串不使用jsonrequest。使用简单请求类。你的问题是很简单的服务器给后面的一个jsonarray只有一个元素里面。一个jsonarray不是JSONObject。这就是解析失败的原因。
volley.NoConnectionError
com.android.volley.NoConnectionError:
java.net.ConnectException:failed to connect to /192.168.0.105(port 80) after 5000ms:isConnected failed:EHOSTUNREACH(No route to host)
无法连接到/ 192.168.0.105(端口80)后5000ms:连接失败:EHOSTUNREACH(没有路由到主机)
服务器相应超时。请检查接口。
本文探讨了在使用Android Volley库时遇到的两种常见错误:ParseError和NoConnectionError,并提供了详细的解决方案。对于ParseError,主要是由于服务器返回的数据不符合预期的JSON格式,解决方法包括检查服务器返回的JSON数据的有效性及调整请求方式。而对于NoConnectionError,则通常是因为网络连接问题导致,如地址不可达等。
572

被折叠的 条评论
为什么被折叠?



