我在设备上测试我的应用程序时遇到问题。
我已经从我的设备中成功打开了浏览器中的localhost,但是当我输入我的ip以将我的应用程序与Web服务连接时,它无效。
我总是得到“不幸的是,[我的应用程序名称]已停止”消息。
谁知道这个问题,请帮助我。我真的需要帮助来解决这个问题。非常感谢你
logcat - 我从设备上的usb debug获取它
06-10 11:31:15.551: D/dalvikvm(14590): Late-enabling CheckJNI
06-10 11:31:15.809: D/TextLayoutCache(14590): Using debug level: 0 - Debug Enabled: 0
06-10 11:31:15.902: D/libEGL(14590): loaded /vendor/lib/egl/libEGL_POWERVR_SGX540_120.so
06-10 11:31:15.910: D/libEGL(14590): loaded /vendor/lib/egl/libGLESv1_CM_POWERVR_SGX540_120.so
06-10 11:31:15.910: D/libEGL(14590): loaded /vendor/lib/egl/libGLESv2_POWERVR_SGX540_120.so
06-10 11:31:16.160: D/OpenGLRenderer(14590): Enabling debug mode 0
06-10 11:31:19.770: D/OpenGLRenderer(14590): Flushing caches (mode 0)
06-10 11:31:22.309: D/OpenGLRenderer(14590): Flushing caches (mode 0)
06-10 11:31:30.848: D/TryLoginCheck(14590): Here
06-10 11:31:30.848: I/System.out(14590): UserNametes
06-10 11:31:30.848: I/System.out(14590): passwordTes12345*
06-10 11:31:30.848: D/Parameters(14590): username=tes&password=Tes12345*
06-10 11:31:30.863: D/AndroidRuntime(14590): Shutting down VM
06-10 11:31:30.863: W/dalvikvm(14590): threadid=1: thread exiting with uncaught exception (group=0x40bd31f8)
06-10 11:31:30.863: E/AndroidRuntime(14590): FATAL EXCEPTION: main
06-10 11:31:30.863: E/AndroidRuntime(14590): android.os.NetworkOnMainThreadException
06-10 11:31:30.863: E/AndroidRuntime(14590): at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1099)
06-10 11:31:30.863: E/AndroidRuntime(14590): at libcore.io.BlockGuardOs.connect(BlockGuardOs.java:84)
06-10 11:31:30.863: E/AndroidRuntime(14590): at libcore.io.IoBridge.connectErrno(IoBridge.java:127)
06-10 11:31:30.863: E/AndroidRuntime(14590): at libcore.io.IoBridge.connect(IoBridge.java:112)
06-10 11:31:30.863: E/AndroidRuntime(14590): at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:192)
06-10 11:31:30.863: E/AndroidRuntime(14590): at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:459)
06-10 11:31:30.863: E/AndroidRuntime(14590): at java.net.Socket.connect(Socket.java:842)
06-10 11:31:30.863: E/AndroidRuntime(14590): at libcore.net.http.HttpConnection.<init>(HttpConnection.java:77)
06-10 11:31:30.863: E/AndroidRuntime(14590): at libcore.net.http.HttpConnection.<init>(HttpConnection.java:50)
06-10 11:31:30.863: E/AndroidRuntime(14590): at libcore.net.http.HttpConnection$Address.connect(HttpConnection.java:351)
06-10 11:31:30.863: E/AndroidRuntime(14590): at libcore.net.http.HttpConnectionPool.get(HttpConnectionPool.java:86)
06-10 11:31:30.863: E/AndroidRuntime(14590): at libcore.net.http.HttpConnection.connect(HttpConnection.java:128)
06-10 11:31:30.863: E/AndroidRuntime(14590): at libcore.net.http.HttpEngine.openSocketConnection(HttpEngine.java:308)
06-10 11:31:30.863: E/AndroidRuntime(14590): at libcore.net.http.HttpEngine.connect(HttpEngine.java:303)
06-10 11:31:30.863: E/AndroidRuntime(14590): at libcore.net.http.HttpEngine.sendSocketRequest(HttpEngine.java:282)
06-10 11:31:30.863: E/AndroidRuntime(14590): at libcore.net.http.HttpEngine.sendRequest(HttpEngine.java:232)
06-10 11:31:30.863: E/AndroidRuntime(14590): at libcore.net.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:80)
06-10 11:31:30.863: E/AndroidRuntime(14590): at libcore.net.http.HttpURLConnectionImpl.getOutputStream(HttpURLConnectionImpl.java:188)
06-10 11:31:30.863: E/AndroidRuntime(14590): at com.karismaelearning.Login.tryLogin(Login.java:128)
06-10 11:31:30.863: E/AndroidRuntime(14590): at com.karismaelearning.Login$3.onClick(Login.java:73)
06-10 11:31:30.863: E/AndroidRuntime(14590): at android.view.View.performClick(View.java:3558)
06-10 11:31:30.863: E/AndroidRuntime(14590): at android.view.View$PerformClick.run(View.java:14157)
06-10 11:31:30.863: E/AndroidRuntime(14590): at android.os.Handler.handleCallback(Handler.java:605)
06-10 11:31:30.863: E/AndroidRuntime(14590): at android.os.Handler.dispatchMessage(Handler.java:92)
06-10 11:31:30.863: E/AndroidRuntime(14590): at android.os.Looper.loop(Looper.java:137)
06-10 11:31:30.863: E/AndroidRuntime(14590): at android.app.ActivityThread.main(ActivityThread.java:4514)
06-10 11:31:30.863: E/AndroidRuntime(14590): at java.lang.reflect.Method.invokeNative(Native Method)
06-10 11:31:30.863: E/AndroidRuntime(14590): at java.lang.reflect.Method.invoke(Method.java:511)
06-10 11:31:30.863: E/AndroidRuntime(14590): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790)
06-10 11:31:30.863: E/AndroidRuntime(14590): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
06-10 11:31:30.863: E/AndroidRuntime(14590): at dalvik.system.NativeStart.main(Native Method)
06-10 11:31:30.918: D/dalvikvm(14590): GC_CONCURRENT freed 237K, 6% free 6863K/7239K, paused 2ms+2ms
答案 0 :(得分:0)
您将获得android.os.NetworkOnMainThreadException
:
当应用程序尝试在其主线程上执行网络操作时引发的异常。
仅针对Honeycomb SDK或更高版本的应用程序进行此操作。针对早期SDK版本的应用程序可以在其主要事件循环线程上进行联网,但是非常不鼓励。
在AsyncTask
侧