【发布时间】:2017-09-20 04:46:26
【问题描述】:
当我应用了一个使用谷库的简单代码时,我使用了谷歌示例“https://developer.android.com/training/volley/simple.html#simple”
RequestQueue queue = Volley.newRequestQueue(getApplicationContext());
String url ="http://www.google.com";
// Request a string response from the provided URL.
StringRequest stringRequest = new StringRequest(Request.Method.GET, url,
new Response.Listener<String>() {
@Override
public void onResponse(String response) {
// Display the first 500 characters of the response string.
message.setText("Response is: "+ response.substring(0,500));
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
message.setText("That didn't work!");
}
});
// Add the request to the RequestQueue.
queue.add(stringRequest);
我得到以下错误。
E/Volley:[77336] NetworkDispatcher.run:未处理的异常 java.lang.NullPointerException:尝试从空对象引用上的字段“int java.lang.String.offset”读取 java.lang.NullPointerException:尝试从空对象引用上的字段“int java.lang.String.offset”读取 在 java.lang.String.compareToIgnoreCase(String.java:560) 在 java.lang.String$CaseInsensitiveComparator.compare(String.java:77) 在 java.lang.String$CaseInsensitiveComparator.compare(String.java:66) 在 java.util.TreeMap.find(TreeMap.java:277) 在 java.util.TreeMap.putInternal(TreeMap.java:240) 在 java.util.TreeMap.put(TreeMap.java:186) 在 com.android.volley.NetworkResponse.toHeaderMap(NetworkResponse.java:138) 在 com.android.volley.NetworkResponse.(NetworkResponse.java:0) 在 com.android.volley.toolbox.BasicNetwork.performRequest(BasicNetwork.java:169) 在 com.android.volley.NetworkDispatcher.run(NetworkDispatcher.java:113)
【问题讨论】:
-
你能告诉我哪一行有错误(Logcat Pointing line)吗?
-
其实我不知道你说的Pointing line是什么意思,就是我申请的时候出现的错误。
标签: java android rest api android-volley