我在android开发中多次遇到未捕获的异常,导致线程在没有进一步调试信息的情况下退出。目前,我的 logcat 中的消息如下所示:
10-24 21:06:56.762: W/dalvikvm(8806): threadid=25: 线程以未捕获的异常退出 (group=0x410a8438)
但是,当我在互联网上搜索试图找到如何调试类似消息时,人们通常会发布类似“
04-25 19:35:02.353: W/dalvikvm(5650): threadid=1: thread exiting with uncaught exception (group=0x40a71930)
04-25 19:35:02.393: E/AndroidRuntime(5650): FATAL EXCEPTION: main
04-25 19:35:02.393: E/AndroidRuntime(5650): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.least/com.example.least.MainActivity}: android.os.NetworkOnMainThreadException
04-25 19:35:02.393: E/AndroidRuntime(5650): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
04-25 19:35:02.393: E/AndroidRuntime(5650): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
04-25 19:35:02.393: E/AndroidRuntime(5650): at android.app.ActivityThread.access$600(ActivityThread.java:141)
04-25 19:35:02.393: E/AndroidRuntime(5650): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
04-25 19:35:02.393: E/AndroidRuntime(5650): at android.os.Handler.dispatchMessage(Handler.java:99)
04-25 19:35:02.393: E/AndroidRuntime(5650): at android.os.Looper.loop(Looper.java:137)
04-25 19:35:02.393: E/AndroidRuntime(5650): at android.app.ActivityThread.main(ActivityThread.java:5041)
04-25 19:35:02.393: E/AndroidRuntime(5650): at java.lang.reflect.Method.invokeNative(Native Method)
04-25 19:35:02.393: E/AndroidRuntime(5650): at java.lang.reflect.Method.invoke(Method.java:511)
04-25 19:35:02.393: E/AndroidRuntime(5650): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
04-25 19:35:02.393: E/AndroidRuntime(5650): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
04-25 19:35:02.393: E/AndroidRuntime(5650): at dalvik.system.NativeStart.main(Native Method)
04-25 19:35:02.393: E/AndroidRuntime(5650): Caused by: android.os.NetworkOnMainThreadException
04-25 19:35:02.393: E/AndroidRuntime(5650): at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1117)
04-25 19:35:02.393: E/AndroidRuntime(5650): at java.net.InetAddress.lookupHostByName(InetAddress.java:385)
04-25 19:35:02.393: E/AndroidRuntime(5650): at java.net.InetAddress.getAllByNameImpl(InetAddress.java:236)
04-25 19:35:02.393: E/AndroidRuntime(5650): at java.net.InetAddress.getAllByName(InetAddress.java:214)
04-25 19:35:02.393: E/AndroidRuntime(5650): at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:137)
04-25 19:35:02.393: E/AndroidRuntime(5650): at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)
04-25 19:35:02.393: E/AndroidRuntime(5650): at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119)
后者显然包含更多有用的调试信息,正如“Caused by”子句通常所建议的那样,而我的 logcat 输出除了混淆了真正的问题之外什么也没做,尽管我已经将调试级别设置为详细。
这是配置问题吗?如何配置我的 logcat 以显示更具启发性的内容?