我的Android应用程序如何打开一个端口进行收听?

时间:2012-11-20 07:23:34

标签: android port

我希望我的Android应用程序充当客户端并侦听特定端口。我试过的代码都没有。我尝试this tutorial来创建一个小型聊天应用。服务器端工作正常,但应用程序崩溃在我的设备上。我在VPN上同时拥有我的手机和服务器。

返回了logcat文本:

11-20 12:39:12.789: W/dalvikvm(12045): threadid=1: thread exiting with uncaught exception (group=0x4017c560)
11-20 12:39:12.799: E/AndroidRuntime(12045): FATAL EXCEPTION: main
11-20 12:39:12.799: E/AndroidRuntime(12045): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.android_port/com.example.android_port.MainActivity}: java.lang.ClassNotFoundException: com.example.android_port.MainActivity in loader dalvik.system.PathClassLoader[/data/app/com.example.android_port-1.apk]
11-20 12:39:12.799: E/AndroidRuntime(12045):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1573)
11-20 12:39:12.799: E/AndroidRuntime(12045):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
11-20 12:39:12.799: E/AndroidRuntime(12045):    at android.app.ActivityThread.access$1500(ActivityThread.java:117)
11-20 12:39:12.799: E/AndroidRuntime(12045):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
11-20 12:39:12.799: E/AndroidRuntime(12045):    at android.os.Handler.dispatchMessage(Handler.java:99)
11-20 12:39:12.799: E/AndroidRuntime(12045):    at android.os.Looper.loop(Looper.java:130)
11-20 12:39:12.799: E/AndroidRuntime(12045):    at android.app.ActivityThread.main(ActivityThread.java:3687)
11-20 12:39:12.799: E/AndroidRuntime(12045):    at java.lang.reflect.Method.invokeNative(Native Method)
11-20 12:39:12.799: E/AndroidRuntime(12045):    at java.lang.reflect.Method.invoke(Method.java:507)
11-20 12:39:12.799: E/AndroidRuntime(12045):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:878)
11-20 12:39:12.799: E/AndroidRuntime(12045):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:636)
11-20 12:39:12.799: E/AndroidRuntime(12045):    at dalvik.system.NativeStart.main(Native Method)
11-20 12:39:12.799: E/AndroidRuntime(12045): Caused by: java.lang.ClassNotFoundException: com.example.android_port.MainActivity in loader dalvik.system.PathClassLoader[/data/app/com.example.android_port-1.apk]
11-20 12:39:12.799: E/AndroidRuntime(12045):    at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
11-20 12:39:12.799: E/AndroidRuntime(12045):    at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
11-20 12:39:12.799: E/AndroidRuntime(12045):    at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
11-20 12:39:12.799: E/AndroidRuntime(12045):    at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
11-20 12:39:12.799: E/AndroidRuntime(12045):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1565)
11-20 12:39:12.799: E/AndroidRuntime(12045):    ... 11 more

0 个答案:

没有答案