我正在将一台消息从一台机器上的一个仿真器实例传输到同一台机器上的另一个仿真器实例。
服务器在机器A上运行。它运行完美(我猜) 客户端运行正常。但当我点击一个按钮将数据从客户端传输到服务器时,我得到了 (scoket,getoutputstream())中的空指针异常
PrintWriter out = new PrintWriter(new BufferedWriter(
new OutputStreamWriter(socket.getOutputStream())),
true);
我有时也会在客户端
中获得权限用户错误我已完成所有重定向,并在android清单文件中添加了INTERNET标记,
我让服务器崩溃但权限被拒绝错误但是在我添加了Internet允许标记服务器工作之后.. 但是当我将相同的标记添加到客户端的清单文件时,客户端崩溃了
因此无法通过添加INTERNET标记来删除权限被拒绝错误 同时我无法清除NULLPOINTER异常
客户端和本地计算机也有不同的时区。 默认情况下,android模拟器不会使用Local TZ。
所以我设置了-timezone选项,即使这样也不会改变timzone区域 AFAIK我想我正在做的事情,对端口和ips。 创建套接字时没有错误,但仅在使用socket.ouputstream时? 有没有防火墙问题。 ?
我进行了广泛的搜索,但不确定问题是什么。 期待您的帮助。 感谢。
我正在使用来自NickT的客户端服务器代码 Connecting 2 Emulator instances In Android 并修改了一点 我得到了错误3 当我打印错误时:
11-25 18:59:06.185: W/System.err(388): java.net.SocketException: Permission denied
11-25 18:59:06.185: W/System.err(388): at org.apache.harmony.luni.platform.OSNetworkSystem.socket(Native Method)
11-25 18:59:06.185: W/System.err(388): at dalvik.system.BlockGuard$WrappedNetworkSystem.socket(BlockGuard.java:347)
11-25 18:59:06.185: W/System.err(388): at org.apache.harmony.luni.net.PlainSocketImpl.create(PlainSocketImpl.java:220)
11-25 18:59:06.185: W/System.err(388): at java.net.Socket.startupSocket(Socket.java:618)
11-25 18:59:06.185: W/System.err(388): at java.net.Socket.<init>(Socket.java:258)
11-25 18:59:06.185: W/System.err(388): at net.wipp.ece.ClAct.onCreate(ClAct.java:40)
11-25 18:59:06.185: W/System.err(388): at android.app.Activity.performCreate(Activity.java:4397)
11-25 18:59:06.185: W/System.err(388): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1048)
11-25 18:59:06.185: W/System.err(388): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1779)
11-25 18:59:06.185: W/System.err(388): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1831)
11-25 18:59:06.185: W/System.err(388): at android.app.ActivityThread.access$500(ActivityThread.java:122)
11-25 18:59:06.185: W/System.err(388): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1024)
11-25 18:59:06.185: W/System.err(388): at android.os.Handler.dispatchMessage(Handler.java:99)
11-25 18:59:06.185: W/System.err(388): at android.os.Looper.loop(Looper.java:132)
11-25 18:59:06.185: W/System.err(388): at android.app.ActivityThread.main(ActivityThread.java:4123)
11-25 18:59:06.185: W/System.err(388): at java.lang.reflect.Method.invokeNative(Native Method)
11-25 18:59:06.185: W/System.err(388): at java.lang.reflect.Method.invoke(Method.java:491)
11-25 18:59:06.185: W/System.err(388): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
11-25 18:59:06.185: W/System.err(388): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
11-25 18:59:06.185: W/System.err(388): at dalvik.system.NativeStart.main(Native Method)
11-25 19:00:14.045: W/System.err(388): java.lang.NullPointerException
11-25 19:00:14.055: W/System.err(388): at net.wipp.ece.ClAct$1.onClick(ClAct.java:54)
11-25 19:00:14.055: W/System.err(388): at android.view.View.performClick(View.java:3110)
11-25 19:00:14.065: W/System.err(388): at android.view.View$PerformClick.run(View.java:11934)
11-25 19:00:14.065: W/System.err(388): at android.os.Handler.handleCallback(Handler.java:587)
11-25 19:00:14.065: W/System.err(388): at android.os.Handler.dispatchMessage(Handler.java:92)
11-25 19:00:14.065: W/System.err(388): at android.os.Looper.loop(Looper.java:132)
11-25 19:00:14.065: W/System.err(388): at android.app.ActivityThread.main(ActivityThread.java:4123)
11-25 19:00:14.065: W/System.err(388): at java.lang.reflect.Method.invokeNative(Native Method)
11-25 19:00:14.065: W/System.err(388): at java.lang.reflect.Method.invoke(Method.java:491)
11-25 19:00:14.065: W/System.err(388): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
11-25 19:00:14.065: W/System.err(388): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
11-25 19:00:14.065: W/System.err(388): at dalvik.system.NativeStart.main(Native Method)
11-25 19:19:45.285: D/dalvikvm(388): GC_CONCURRENT freed 349K, 7% free 6380K/6791K, paused 10ms+2ms
11-25 19:26:27.115: I/dalvikvm(388): Jit: resizing JitTable from 512 to 1024
11-25 19:49:48.055: D/dalvikvm(388): GC_CONCURRENT freed 419K, 8% free 6378K/6919K, paused 7ms+2ms
11-25 20:19:58.565: D/dalvikvm(388): GC_CONCURRENT freed 419K, 8% free 6378K/6919K, paused 7ms+2ms
11-25 20:45:27.594: I/dalvikvm(388): Jit: resizing JitTable from 1024 to 2048
11-25 20:50:09.304: D/dalvikvm(388): GC_CONCURRENT freed 419K, 8% free 6378K/6919K, paused 7ms+3ms
11-25 21:20:19.785: D/dalvikvm(388): GC_CONCURRENT freed 419K, 8% free 6378K/6919K, paused 4ms+2ms
11-25 21:50:29.924: D/dalvikvm(388): GC_CONCURRENT freed 419K, 8% free 6378K/6919K, paused 8ms+5ms
11-25 22:20:40.565: D/dalvikvm(388): GC_CONCURRENT freed 419K, 8% free 6378K/6919K, paused 8ms+3ms
11-25 22:50:50.675: D/dalvikvm(388): GC_CONCURRENT freed 419K, 8% free 6378K/6919K, paused 7ms+2ms
11-25 23:21:00.474: D/dalvikvm(388): GC_CONCURRENT freed 419K, 8% free 6378K/6919K, paused 5ms+4ms
11-25 23:51:10.485: D/dalvikvm(388): GC_CONCURRENT freed 419K, 8% free 6378K/6919K, paused 11ms+3ms
11-26 00:21:20.725: D/dalvikvm(388): GC_CONCURRENT freed 419K, 8% free 6378K/6919K, paused 8ms+2ms
11-26 00:51:30.835: D/dalvikvm(388): GC_CONCURRENT freed 419K, 8% free 6378K/6919K, paused 8ms+3ms
11-26 01:21:41.254: D/dalvikvm(388): GC_CONCURRENT freed 419K, 8% free 6378K/6919K, paused 12ms+4ms
11-26 01:48:27.275: W/System.err(388): java.lang.NullPointerException
11-26 01:48:27.275: W/System.err(388): at net.wipp.ece.ClAct$1.onClick(ClAct.java:54)
11-26 01:48:27.275: W/System.err(388): at android.view.View.performClick(View.java:3110)
11-26 01:48:27.275: W/System.err(388): at android.view.View$PerformClick.run(View.java:11934)
11-26 01:48:27.275: W/System.err(388): at android.os.Handler.handleCallback(Handler.java:587)
11-26 01:48:27.275: W/System.err(388): at android.os.Handler.dispatchMessage(Handler.java:92)
11-26 01:48:27.285: W/System.err(388): at android.os.Looper.loop(Looper.java:132)
11-26 01:48:27.285: W/System.err(388): at android.app.ActivityThread.main(ActivityThread.java:4123)
11-26 01:48:27.285: W/System.err(388): at java.lang.reflect.Method.invokeNative(Native Method)
11-26 01:48:27.285: W/System.err(388): at java.lang.reflect.Method.invoke(Method.java:491)
11-26 01:48:27.295: W/System.err(388): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
11-26 01:48:27.295: W/System.err(388): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
11-26 01:48:27.295: W/System.err(388): at dalvik.system.NativeStart.main(Native Method)
11-26 01:48:32.734: W/System.err(388): java.lang.NullPointerException
11-26 01:48:32.744: W/System.err(388): at net.wipp.ece.ClAct$1.onClick(ClAct.java:54)
11-26 01:48:32.744: W/System.err(388): at android.view.View.performClick(View.java:3110)
11-26 01:48:32.744: W/System.err(388): at android.view.View$PerformClick.run(View.java:11934)
11-26 01:48:32.744: W/System.err(388): at android.os.Handler.handleCallback(Handler.java:587)
11-26 01:48:32.744: W/System.err(388): at android.os.Handler.dispatchMessage(Handler.java:92)
11-26 01:48:32.744: W/System.err(388): at android.os.Looper.loop(Looper.java:132)
11-26 01:48:32.744: W/System.err(388): at android.app.ActivityThread.main(ActivityThread.java:4123)
11-26 01:48:32.744: W/System.err(388): at java.lang.reflect.Method.invokeNative(Native Method)
11-26 01:48:32.744: W/System.err(388): at java.lang.reflect.Method.invoke(Method.java:491)
11-26 01:48:32.744: W/System.err(388): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
11-26 01:48:32.754: W/System.err(388): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
11-26 01:48:32.754: W/System.err(388): at dalvik.system.NativeStart.main(Native Method)
11-26 01:48:32.945: W/System.err(388): java.lang.NullPointerException
11-26 01:48:32.945: W/System.err(388): at net.wipp.ece.ClAct$1.onClick(ClAct.java:54)
11-26 01:48:32.945: W/System.err(388): at android.view.View.performClick(View.java:3110)
11-26 01:48:32.945: W/System.err(388): at android.view.View$PerformClick.run(View.java:11934)
11-26 01:48:32.945: W/System.err(388): at android.os.Handler.handleCallback(Handler.java:587)
11-26 01:48:32.955: W/System.err(388): at android.os.Handler.dispatchMessage(Handler.java:92)
11-26 01:48:32.955: W/System.err(388): at android.os.Looper.loop(Looper.java:132)
11-26 01:48:32.955: W/System.err(388): at android.app.ActivityThread.main(ActivityThread.java:4123)
11-26 01:48:32.955: W/System.err(388): at java.lang.reflect.Method.invokeNative(Native Method)
11-26 01:48:32.955: W/System.err(388): at java.lang.reflect.Method.invoke(Method.java:491)
11-26 01:48:32.955: W/System.err(388): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
11-26 01:48:32.955: W/System.err(388): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
11-26 01:48:32.955: W/System.err(388): at dalvik.system.NativeStart.main(Native Method)
11-26 01:48:33.116: W/System.err(388): java.lang.NullPointerException
11-26 01:48:33.116: W/System.err(388): at net.wipp.ece.ClAct$1.onClick(ClAct.java:54)
11-26 01:48:33.116: W/System.err(388): at android.view.View.performClick(View.java:3110)
11-26 01:48:33.116: W/System.err(388): at android.view.View$PerformClick.run(View.java:11934)
11-26 01:48:33.116: W/System.err(388): at android.os.Handler.handleCallback(Handler.java:587)
11-26 01:48:33.116: W/System.err(388): at android.os.Handler.dispatchMessage(Handler.java:92)
11-26 01:48:33.116: W/System.err(388): at android.os.Looper.loop(Looper.java:132)
11-26 01:48:33.125: W/System.err(388): at android.app.ActivityThread.main(ActivityThread.java:4123)
11-26 01:48:33.125: W/System.err(388): at java.lang.reflect.Method.invokeNative(Native Method)
11-26 01:48:33.125: W/System.err(388): at java.lang.reflect.Method.invoke(Method.java:491)
11-26 01:48:33.125: W/System.err(388): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
11-26 01:48:33.125: W/System.err(388): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
11-26 01:48:33.155: W/System.err(388): at dalvik.system.NativeStart.main(Native Method)
11-26 01:48:33.195: D/dalvikvm(388): GC_CONCURRENT freed 415K, 8% free 6382K/6919K, paused 4ms+2ms
11-26 01:48:33.305: W/System.err(388): java.lang.NullPointerException
11-26 01:48:33.305: W/System.err(388): at net.wipp.ece.ClAct$1.onClick(ClAct.java:54)
11-26 01:48:33.305: W/System.err(388): at android.view.View.performClick(View.java:3110)
11-26 01:48:33.305: W/System.err(388): at android.view.View$PerformClick.run(View.java:11934)
11-26 01:48:33.305: W/System.err(388): at android.os.Handler.handleCallback(Handler.java:587)
11-26 01:48:33.305: W/System.err(388): at android.os.Handler.dispatchMessage(Handler.java:92)
11-26 01:48:33.305: W/System.err(388): at android.os.Looper.loop(Looper.java:132)
11-26 01:48:33.305: W/System.err(388): at android.app.ActivityThread.main(ActivityThread.java:4123)
11-26 01:48:33.305: W/System.err(388): at java.lang.reflect.Method.invokeNative(Native Method)
11-26 01:48:33.305: W/System.err(388): at java.lang.reflect.Method.invoke(Method.java:491)
11-26 01:48:33.305: W/System.err(388): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
11-26 01:48:33.315: W/System.err(388): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
11-26 01:48:33.315: W/System.err(388): at dalvik.system.NativeStart.main(Native Method)
11-26 01:48:33.455: W/System.err(388): java.lang.NullPointerException
11-26 01:48:33.465: W/System.err(388): at net.wipp.ece.ClAct$1.onClick(ClAct.java:54)
11-26 01:48:33.465: W/System.err(388): at android.view.View.performClick(View.java:3110)
11-26 01:48:33.465: W/System.err(388): at android.view.View$PerformClick.run(View.java:11934)
11-26 01:48:33.465: W/System.err(388): at android.os.Handler.handleCallback(Handler.java:587)
11-26 01:48:33.465: W/System.err(388): at android.os.Handler.dispatchMessage(Handler.java:92)
11-26 01:48:33.475: W/System.err(388): at android.os.Looper.loop(Looper.java:132)
11-26 01:48:33.475: W/System.err(388): at android.app.ActivityThread.main(ActivityThread.java:4123)
11-26 01:48:33.475: W/System.err(388): at java.lang.reflect.Method.invokeNative(Native Method)
11-26 01:48:33.475: W/System.err(388): at java.lang.reflect.Method.invoke(Method.java:491)
11-26 01:48:33.475: W/System.err(388): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
11-26 01:48:33.475: W/System.err(388): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
11-26 01:48:33.475: W/System.err(388): at dalvik.system.NativeStart.main(Native Method)
11-26 01:48:33.764: W/System.err(388): java.lang.NullPointerException
11-26 01:48:33.764: W/System.err(388): at net.wipp.ece.ClAct$1.onClick(ClAct.java:54)
11-26 01:48:33.764: W/System.err(388): at android.view.View.performClick(View.java:3110)
11-26 01:48:33.764: W/System.err(388): at android.view.View$PerformClick.run(View.java:11934)
11-26 01:48:33.764: W/System.err(388): at android.os.Handler.handleCallback(Handler.java:587)
11-26 01:48:33.764: W/System.err(388): at android.os.Handler.dispatchMessage(Handler.java:92)
11-26 01:48:33.774: W/System.err(388): at android.os.Looper.loop(Looper.java:132)
11-26 01:48:33.774: W/System.err(388): at android.app.ActivityThread.main(ActivityThread.java:4123)
11-26 01:48:33.774: W/System.err(388): at java.lang.reflect.Method.invokeNative(Native Method)
11-26 01:48:33.774: W/System.err(388): at java.lang.reflect.Method.invoke(Method.java:491)
11-26 01:48:33.774: W/System.err(388): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
11-26 01:48:33.774: W/System.err(388): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
11-26 01:48:33.774: W/System.err(388): at dalvik.system.NativeStart.main(Native Method)
11-26 01:50:49.035: W/System.err(472): java.net.SocketException: Permission denied
11-26 01:50:49.035: W/System.err(472): at org.apache.harmony.luni.platform.OSNetworkSystem.socket(Native Method)
11-26 01:50:49.035: W/System.err(472): at dalvik.system.BlockGuard$WrappedNetworkSystem.socket(BlockGuard.java:347)
11-26 01:50:49.035: W/System.err(472): at org.apache.harmony.luni.net.PlainSocketImpl.create(PlainSocketImpl.java:220)
11-26 01:50:49.045: W/System.err(472): at java.net.Socket.startupSocket(Socket.java:618)
11-26 01:50:49.045: W/System.err(472): at java.net.Socket.<init>(Socket.java:258)
11-26 01:50:49.045: W/System.err(472): at net.wipp.ece.ClAct.onCreate(ClAct.java:40)
11-26 01:50:49.045: W/System.err(472): at android.app.Activity.performCreate(Activity.java:4397)
11-26 01:50:49.045: W/System.err(472): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1048)
11-26 01:50:49.045: W/System.err(472): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1779)
11-26 01:50:49.045: W/System.err(472): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1831)
11-26 01:50:49.045: W/System.err(472): at android.app.ActivityThread.access$500(ActivityThread.java:122)
11-26 01:50:49.045: W/System.err(472): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1024)
11-26 01:50:49.055: W/System.err(472): at android.os.Handler.dispatchMessage(Handler.java:99)
11-26 01:50:49.055: W/System.err(472): at android.os.Looper.loop(Looper.java:132)
11-26 01:50:49.055: W/System.err(472): at android.app.ActivityThread.main(ActivityThread.java:4123)
11-26 01:50:49.055: W/System.err(472): at java.lang.reflect.Method.invokeNative(Native Method)
11-26 01:50:49.055: W/System.err(472): at java.lang.reflect.Method.invoke(Method.java:491)
11-26 01:50:49.055: W/System.err(472): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
11-26 01:50:49.055: W/System.err(472): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
11-26 01:50:49.055: W/System.err(472): at dalvik.system.NativeStart.main(Native Method)
11-26 01:50:54.375: E/Client(472): java.lang.NullPointerException
11-26 01:50:54.375: E/Client(472): at net.wipp.ece.ClAct$1.onClick(ClAct.java:54)
11-26 01:50:54.375: E/Client(472): at android.view.View.performClick(View.java:3110)
11-26 01:50:54.375: E/Client(472): at android.view.View$PerformClick.run(View.java:11934)
11-26 01:50:54.375: E/Client(472): at android.os.Handler.handleCallback(Handler.java:587)
11-26 01:50:54.375: E/Client(472): at android.os.Handler.dispatchMessage(Handler.java:92)
11-26 01:50:54.375: E/Client(472): at android.os.Looper.loop(Looper.java:132)
11-26 01:50:54.375: E/Client(472): at android.app.ActivityThread.main(ActivityThread.java:4123)
11-26 01:50:54.375: E/Client(472): at java.lang.reflect.Method.invokeNative(Native Method)
11-26 01:50:54.375: E/Client(472): at java.lang.reflect.Method.invoke(Method.java:491)
11-26 01:50:54.375: E/Client(472): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
11-26 01:50:54.375: E/Client(472): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
11-26 01:50:54.375: E/Client(472): at dalvik.system.NativeStart.main(Native Method)
11-26 01:50:54.375: W/System.err(472): java.lang.NullPointerException
11-26 01:50:54.375: W/System.err(472): at net.wipp.ece.ClAct$1.onClick(ClAct.java:54)
11-26 01:50:54.375: W/System.err(472): at android.view.View.performClick(View.java:3110)
11-26 01:50:54.375: W/System.err(472): at android.view.View$PerformClick.run(View.java:11934)
11-26 01:50:54.375: W/System.err(472): at android.os.Handler.handleCallback(Handler.java:587)
11-26 01:50:54.385: W/System.err(472): at android.os.Handler.dispatchMessage(Handler.java:92)
11-26 01:50:54.385: W/System.err(472): at android.os.Looper.loop(Looper.java:132)
11-26 01:50:54.385: W/System.err(472): at android.app.ActivityThread.main(ActivityThread.java:4123)
11-26 01:50:54.385: W/System.err(472): at java.lang.reflect.Method.invokeNative(Native Method)
11-26 01:50:54.385: W/System.err(472): at java.lang.reflect.Method.invoke(Method.java:491)
11-26 01:50:54.385: W/System.err(472): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
11-26 01:50:54.385: W/System.err(472): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
11-26 01:50:54.385: W/System.err(472): at dalvik.system.NativeStart.main(Native Method)
答案 0 :(得分:0)
异常日志告诉您错误的确切位置:
at net.wipp.ece.ClAct$1.onClick(ClAct.java:54)
这意味着在你的ClAct类中,在onClick方法中,在第54行,某些东西是null。如果设置断点并一直调试到该点,您将看到该行上的某些内容为null。