android项目连接服务器报错
--------------------编程问答-------------------- 你这是空异常,应该是JSON为空造成的,检查一下是否服务器返回了正确的JSON,然后看看有没有网络连接异常。 --------------------编程问答--------------------
java.lang.reflect.Method.invoke(Method.java:515)
12-19 03:19:45.998: W/System.err(1375): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)
12-19 03:19:45.998: W/System.err(1375): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:593)
12-19 03:19:46.008: W/System.err(1375): at dalvik.system.NativeStart.main(Native Method)
12-19 03:19:46.008: W/System.err(1375): org.json.JSONException: End of input at character 0 of
12-19 03:19:46.088: W/System.err(1375): at org.json.JSONTokener.syntaxError(JSONTokener.java:450)
12-19 03:19:46.088: W/System.err(1375): at org.json.JSONTokener.nextValue(JSONTokener.java:97)
12-19 03:19:46.118: W/System.err(1375): at org.json.JSONArray.<init>(JSONArray.java:92)
12-19 03:19:46.118: W/System.err(1375): at org.json.JSONArray.<init>(JSONArray.java:108)
12-19 03:19:46.148: W/System.err(1375): at com.entity.GetJson.jsonType(GetJson.java:166)
12-19 03:19:46.148: W/System.err(1375): at com.example.photowallfallsdemo.ImagesBIL.imageUrlsOfBIL(ImagesBIL.java:9)
12-19 03:19:46.168: W/System.err(1375): at com.example.photowallfallsdemo.MyScrollViewBIL.loadMoreImages(MyScrollViewBIL.java:199)
12-19 03:19:46.168: W/System.err(1375): at com.example.photowallfallsdemo.MyScrollViewBIL.onLayout(MyScrollViewBIL.java:175)
12-19 03:19:46.168: W/System.err(1375): at android.view.View.layout(View.java:14785)
12-19 03:19:46.198: W/System.err(1375): at android.view.ViewGroup.layout(ViewGroup.java:4631)
12-19 03:19:46.198: W/System.err(1375): at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1055)
12-19 03:19:46.198: W/System.err(1375): at android.view.View.layout(View.java:14785)
12-19 03:19:46.198: W/System.err(1375): at android.view.ViewGroup.layout(ViewGroup.java:4631)
12-19 03:19:46.198: W/System.err(1375): at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
12-19 03:19:46.198: W/System.err(1375): at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
12-19 03:19:46.198: W/System.err(1375): at android.view.View.layout(View.java:14785)
12-19 03:19:46.198: W/System.err(1375): at android.view.ViewGroup.layout(ViewGroup.java:4631)
12-19 03:19:46.198: W/System.err(1375): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1671)
12-19 03:19:46.198: W/System.err(1375): at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1525)
12-19 03:19:46.198: W/System.err(1375): at android.widget.LinearLayout.onLayout(LinearLayout.java:1434)
12-19 03:19:46.198: W/System.err(1375): at android.view.View.layout(View.java:14785)
12-19 03:19:46.198: W/System.err(1375): at android.view.ViewGroup.layout(ViewGroup.java:4631)
12-19 03:19:46.198: W/System.err(1375): at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
12-19 03:19:46.198: W/System.err(1375): at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
12-19 03:19:46.198: W/System.err(1375): at android.view.View.layout(View.java:14785)
12-19 03:19:46.198: W/System.err(1375): at android.view.ViewGroup.layout(ViewGroup.java:4631)
12-19 03:19:46.198: W/System.err(1375): at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:1985)
12-19 03:19:46.198: W/System.err(1375): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1742)
12-19 03:19:46.198: W/System.err(1375): at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:998)
12-19 03:19:46.198: W/System.err(1375): at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5582)
12-19 03:19:46.198: W/System.err(1375): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:749)
12-19 03:19:46.198: W/System.err(1375): at android.view.Choreographer.doCallbacks(Choreographer.java:562)
12-19 03:19:46.198: W/System.err(1375): at android.view.Choreographer.doFrame(Choreographer.java:532)
12-19 03:19:46.198: W/System.err(1375): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:735)
12-19 03:19:46.198: W/System.err(1375): at android.os.Handler.handleCallback(Handler.java:733)
12-19 03:19:46.198: W/System.err(1375): at android.os.Handler.dispatchMessage(Handler.java:95)
12-19 03:19:46.198: W/System.err(1375): at android.os.Looper.loop(Looper.java:137)
12-19 03:19:46.258: W/System.err(1375): at android.app.ActivityThread.main(ActivityThread.java:4998)
12-19 03:19:46.288: W/System.err(1375): at java.lang.reflect.Method.invokeNative(Native Method)
12-19 03:19:46.318: W/System.err(1375): at java.lang.reflect.Method.invoke(Method.java:515)
12-19 03:19:46.378: W/System.err(1375): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)
12-19 03:19:46.378: W/System.err(1375): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:593)
12-19 03:19:46.378: W/System.err(1375): at dalvik.system.NativeStart.main(Native Method)
12-19 03:19:46.388: D/AndroidRuntime(1375): Shutting down VM
12-19 03:19:46.388: W/dalvikvm(1375): threadid=1: thread exiting with uncaught exception (group=0xb3a5ab90)
12-19 03:19:46.928: D/com.umeng.common.b(1375): Could not get location from GPS or Cell-id, lack ACCESS_COARSE_LOCATION or ACCESS_COARSE_LOCATION permission?
12-19 03:19:47.088: D/MobclickAgent(1375): cache buffer success
12-19 03:19:47.228: D/dalvikvm(1375): GC_FOR_ALLOC freed 354K, 23% free 15721K/20184K, paused 53ms, total 58ms
12-19 03:19:47.248: E/AndroidRuntime(1375): FATAL EXCEPTION: main
12-19 03:19:47.248: E/AndroidRuntime(1375): Process: com.PicGenie, PID: 1375
12-19 03:19:47.248: E/AndroidRuntime(1375): java.lang.NullPointerException
12-19 03:19:47.248: E/AndroidRuntime(1375): at com.entity.GetJson.jsonType(GetJson.java:171)
12-19 03:19:47.248: E/AndroidRuntime(1375): at com.example.photowallfallsdemo.ImagesBIL.imageUrlsOfBIL(ImagesBIL.java:9)
12-19 03:19:47.248: E/AndroidRuntime(1375): at com.example.photowallfallsdemo.MyScrollViewBIL.loadMoreImages(MyScrollViewBIL.java:199)
12-19 03:19:47.248: E/AndroidRuntime(1375): at com.example.photowallfallsdemo.MyScrollViewBIL.onLayout(MyScrollViewBIL.java:175)
12-19 03:19:47.248: E/AndroidRuntime(1375): at android.view.View.layout(View.java:14785)
12-19 03:19:47.248: E/AndroidRuntime(1375): at android.view.ViewGroup.layout(ViewGroup.java:4631)
12-19 03:19:47.248: E/AndroidRuntime(1375): at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1055)
12-19 03:19:47.248: E/AndroidRuntime(1375): at android.view.View.layout(View.java:14785)
12-19 03:19:47.248: E/AndroidRuntime(1375): at android.view.ViewGroup.layout(ViewGroup.java:4631)
12-19 03:19:47.248: E/AndroidRuntime(1375): at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
12-19 03:19:47.248: E/AndroidRuntime(1375): at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
12-19 03:19:47.248: E/AndroidRuntime(1375): at android.view.View.layout(View.java:14785)
12-19 03:19:47.248: E/AndroidRuntime(1375): at android.view.ViewGroup.layout(ViewGroup.java:4631)
12-19 03:19:47.248: E/AndroidRuntime(1375): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1671)
12-19 03:19:47.248: E/AndroidRuntime(1375): at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1525)
12-19 03:19:47.248: E/AndroidRuntime(1375): at android.widget.LinearLayout.onLayout(LinearLayout.java:1434)
12-19 03:19:47.248: E/AndroidRuntime(1375): at android.view.View.layout(View.java:14785)
12-19 03:19:47.248: E/AndroidRuntime(1375): at android.view.ViewGroup.layout(ViewGroup.java:4631)
12-19 03:19:47.248: E/AndroidRuntime(1375): at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
12-19 03:19:47.248: E/AndroidRuntime(1375): at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
12-19 03:19:47.248: E/AndroidRuntime(1375): at android.view.View.layout(View.java:14785)
12-19 03:19:47.248: E/AndroidRuntime(1375): at android.view.ViewGroup.layout(ViewGroup.java:4631)
12-19 03:19:47.248: E/AndroidRuntime(1375): at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:1985)
12-19 03:19:47.248: E/AndroidRuntime(1375): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1742)
12-19 03:19:47.248: E/AndroidRuntime(1375): at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:998)
12-19 03:19:47.248: E/AndroidRuntime(1375): at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5582)
12-19 03:19:47.248: E/AndroidRuntime(1375): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:749)
12-19 03:19:47.248: E/AndroidRuntime(1375): at android.view.Choreographer.doCallbacks(Choreographer.java:562)
12-19 03:19:47.248: E/AndroidRuntime(1375): at android.view.Choreographer.doFrame(Choreographer.java:532)
12-19 03:19:47.248: E/AndroidRuntime(1375): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:735)
12-19 03:19:47.248: E/AndroidRuntime(1375): at android.os.Handler.handleCallback(Handler.java:733)
12-19 03:19:47.248: E/AndroidRuntime(1375): at android.os.Handler.dispatchMessage(Handler.java:95)
12-19 03:19:47.248: E/AndroidRuntime(1375): at android.os.Looper.loop(Looper.java:137)
12-19 03:19:47.248: E/AndroidRuntime(1375): at android.app.ActivityThread.main(ActivityThread.java:4998)
12-19 03:19:47.248: E/AndroidRuntime(1375): at java.lang.reflect.Method.invokeNative(Native Method)
12-19 03:19:47.248: E/AndroidRuntime(1375): at java.lang.reflect.Method.invoke(Method.java:515)
12-19 03:19:47.248: E/AndroidRuntime(1375): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)
12-19 03:19:47.248: E/AndroidRuntime(1375): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:593)
12-19 03:19:47.248: E/AndroidRuntime(1375): at dalvik.system.NativeStart.main(Native Method)
我已经加了判断,如果是空,就返回我给定的这个数组,你看一下我源码,谢谢
public final static String[] imageUrlsOfBIL() {
GetJson urlimage = new GetJson();
if(urlimage.getStrings(urlimage.jsonType("BIL"))==null)
{
final String[] test = new String[] {
"http://b268.photo.store.qq.com/psb?/V116Z8Jx12bQOL/Yy5CuxGLYrfNYQGlgOELGsFTlFTesSSvj5qBNwbUPdo!/b/dPikwJ*iIAAA&bo=WAIgAwAAAAABAF4!&rf=photoDetail",
"http://b268.photo.store.qq.com/psb?/V116Z8Jx12bQOL/Yy5CuxGLYrfNYQGlgOELGsFTlFTesSSvj5qBNwbUPdo!/b/dPikwJ*iIAAA&bo=WAIgAwAAAAABAF4!&rf=photoDetail",
"http://b228.photo.store.qq.com/psb?/V116Z8Jx12bQOL/.3xnkX57HGyxDB*igkiYx*xjnwuSSa00ZohC0*nFjCo!/b/dFlC8ocILQAA&bo=gAJYAwAAAAAKAPU!&rf=photoDetail",
"http://b233.photo.store.qq.com/psb?/V116Z8Jx12bQOL/DhBmngo1u3sRXYgvZR3MVVdghxGiEefUeACM1N9*ts4!/b/dNs77Yq5KAAA&bo=gAJ*AwAAAAAKANI!&rf=photoDetail",
"http://b229.photo.store.qq.com/psb?/V116Z8Jx12bQOL/0mg2WV4Q5rh5pgiLWonSN8fwzNqJr1O0dI.BA7hA3hU!/b/dJd7kogBJQAA&bo=gAJYAwAAAAAKAPU!&rf=photoDetail",
"http://b228.photo.store.qq.com/psb?/V116Z8Jx12bQOL/C6ap*ExKPtoyiBXcmMJsDg0UE8E1huVJ8w8.Sad5jlQ!/b/dE2q6ocYLQAA&bo=gALeAQAAAAABAHo!&rf=photoDetail",
"http://b228.photo.store.qq.com/psb?/V116Z8Jx12bQOL/C6ap*ExKPtoyiBXcmMJsDg0UE8E1huVJ8w8.Sad5jlQ!/b/dE2q6ocYLQAA&bo=gALeAQAAAAABAHo!&rf=photoDetail",
"http://b269.photo.store.qq.com/psb?/V116Z8Jx12bQOL/yrepKOjK71F2.MGsuZo8.YDm*Gvpawf0n8lAMIzEHGs!/b/dExAXKDqGQAA&bo=zwGAAgAAAAABAGs!&rf=photoDetail",
"http://b259.photo.store.qq.com/psb?/V116Z8Jx12bQOL/rlydZygqs9P9OKladeHBsedBwW.9N81mNgPwP8uGM0w!/b/dKeMbJpEFQAA&bo=qQEDAgAAAAADAIw!&rf=photoDetail",
"http://b259.photo.store.qq.com/psb?/V116Z8Jx12bQOL/ts.D1gWgnS.7PdJvGdTq1lkV.YqOvykQjat2O9vnSEk!/b/dOVoZpo6IQAA&bo=gAJVAwAAAAABAPM!&rf=photoDetail",
"http://b269.photo.store.qq.com/psb?/V116Z8Jx12bQOL/Y2agxCf.HtcRVhymB6*CUxfR0d.Nars8dJ12gFpgkoc!/b/dJHYYKBRJQAA&bo=gAJVAwAAAAABAPM!&rf=photoDetail",
"http://b269.photo.store.qq.com/psb?/V116Z8Jx12bQOL/ut9IaqogexhDtki3QdSBzn0bJFPVmULaF9qsrUT.FzY!/b/dL5qX6BEJQAA&bo=gAJVAwAAAAABAPM!&rf=photoDetail&rf=photoDetail",
"http://www.dazhihui008.cn/pic.asp?url=http://img01.mopimg.cn/xianyang/forum/201305/16/115549af37ij4t4i2l6f4u.gif",
};
return test;
}
else
{
return urlimage.getStrings(urlimage.jsonType("BIL"));
}
}
}
这个是报错
12-23 22:04:50.448: D/AndroidRuntime(1061): Shutting down VM--------------------编程问答-------------------- 空异常,确定得到了JSON数据是正确的?
12-23 22:04:50.448: W/dalvikvm(1061): threadid=1: thread exiting with uncaught exception (group=0xb3a75b90)
12-23 22:04:50.678: D/com.umeng.common.b(1061): Could not get location from GPS or Cell-id, lack ACCESS_COARSE_LOCATION or ACCESS_COARSE_LOCATION permission?
12-23 22:04:50.698: D/MobclickAgent(1061): cache buffer success
12-23 22:04:50.768: E/AndroidRuntime(1061): FATAL EXCEPTION: main
12-23 22:04:50.768: E/AndroidRuntime(1061): Process: com.PicGenie, PID: 1061
12-23 22:04:50.768: E/AndroidRuntime(1061): java.lang.NullPointerException
12-23 22:04:50.768: E/AndroidRuntime(1061): at com.entity.GetJson.jsonType(GetJson.java:171)
12-23 22:04:50.768: E/AndroidRuntime(1061): at com.example.photowallfallsdemo.ImagesBIL.imageUrlsOfBIL(ImagesBIL.java:9)
12-23 22:04:50.768: E/AndroidRuntime(1061): at com.example.photowallfallsdemo.MyScrollViewBIL.loadMoreImages(MyScrollViewBIL.java:198)
12-23 22:04:50.768: E/AndroidRuntime(1061): at com.example.photowallfallsdemo.MyScrollViewBIL.onLayout(MyScrollViewBIL.java:174)
12-23 22:04:50.768: E/AndroidRuntime(1061): at android.view.View.layout(View.java:14785)
12-23 22:04:50.768: E/AndroidRuntime(1061): at android.view.ViewGroup.layout(ViewGroup.java:4631)
12-23 22:04:50.768: E/AndroidRuntime(1061): at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1055)
12-23 22:04:50.768: E/AndroidRuntime(1061): at android.view.View.layout(View.java:14785)
12-23 22:04:50.768: E/AndroidRuntime(1061): at android.view.ViewGroup.layout(ViewGroup.java:4631)
12-23 22:04:50.768: E/AndroidRuntime(1061): at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
12-23 22:04:50.768: E/AndroidRuntime(1061): at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
12-23 22:04:50.768: E/AndroidRuntime(1061): at android.view.View.layout(View.java:14785)
12-23 22:04:50.768: E/AndroidRuntime(1061): at android.view.ViewGroup.layout(ViewGroup.java:4631)
12-23 22:04:50.768: E/AndroidRuntime(1061): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1671)
12-23 22:04:50.768: E/AndroidRuntime(1061): at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1525)
12-23 22:04:50.768: E/AndroidRuntime(1061): at android.widget.LinearLayout.onLayout(LinearLayout.java:1434)
12-23 22:04:50.768: E/AndroidRuntime(1061): at android.view.View.layout(View.java:14785)
12-23 22:04:50.768: E/AndroidRuntime(1061): at android.view.ViewGroup.layout(ViewGroup.java:4631)
12-23 22:04:50.768: E/AndroidRuntime(1061): at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
12-23 22:04:50.768: E/AndroidRuntime(1061): at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
12-23 22:04:50.768: E/AndroidRuntime(1061): at android.view.View.layout(View.java:14785)
12-23 22:04:50.768: E/AndroidRuntime(1061): at android.view.ViewGroup.layout(ViewGroup.java:4631)
12-23 22:04:50.768: E/AndroidRuntime(1061): at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:1985)
12-23 22:04:50.768: E/AndroidRuntime(1061): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1742)
12-23 22:04:50.768: E/AndroidRuntime(1061): at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:998)
12-23 22:04:50.768: E/AndroidRuntime(1061): at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5582)
12-23 22:04:50.768: E/AndroidRuntime(1061): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:749)
12-23 22:04:50.768: E/AndroidRuntime(1061): at android.view.Choreographer.doCallbacks(Choreographer.java:562)
12-23 22:04:50.768: E/AndroidRuntime(1061): at android.view.Choreographer.doFrame(Choreographer.java:532)
12-23 22:04:50.768: E/AndroidRuntime(1061): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:735)
12-23 22:04:50.768: E/AndroidRuntime(1061): at android.os.Handler.handleCallback(Handler.java:733)
12-23 22:04:50.768: E/AndroidRuntime(1061): at android.os.Handler.dispatchMessage(Handler.java:95)
12-23 22:04:50.768: E/AndroidRuntime(1061): at android.os.Looper.loop(Looper.java:137)
12-23 22:04:50.768: E/AndroidRuntime(1061): at android.app.ActivityThread.main(ActivityThread.java:4998)
12-23 22:04:50.768: E/AndroidRuntime(1061): at java.lang.reflect.Method.invokeNative(Native Method)
12-23 22:04:50.768: E/AndroidRuntime(1061): at java.lang.reflect.Method.invoke(Method.java:515)
12-23 22:04:50.768: E/AndroidRuntime(1061): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)
12-23 22:04:50.768: E/AndroidRuntime(1061): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:593)
12-23 22:04:50.768: E/AndroidRuntime(1061): at dalvik.system.NativeStart.main(Native Method)
12-23 22:04:51.008: D/dalvikvm(1061): GC_FOR_ALLOC freed 360K, 22% free 15719K/20048K, paused 95ms, total 101ms
补充:移动开发 , Android