默认启用堆栈跟踪
当我做这样的事情时:
try{
row=inflater.inflate(R.layout.row2, parent, false);
}catch(Exception e){
Log.e(TAG,"error",e);
}
我得到了 LogCat 中预期的堆栈跟踪。 然而,如果没有它,错误就不会被捕获,但我仍然期望在未过滤的日志中出现跟踪。但为什么没有呢?如果没有它,我只能在“调试”选项卡(调用堆栈?)中看到异常状态。有些地方无法使用 try..catch,例如在 xml 文件中。
现在我面临运行时异常。未过滤的日志是这样的:
09-06 20:48:22.760: DEBUG/dalvikvm(11430): GC_EXPLICIT freed 100K, 51% free 2658K/5379K, external 0K/0K, paused 97ms
09-06 20:48:24.329: DEBUG/AndroidRuntime(11805): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
09-06 20:48:24.329: DEBUG/AndroidRuntime(11805): CheckJNI is OFF
09-06 20:48:24.329: DEBUG/AndroidRuntime(11805): setted country_code = The Netherlands
09-06 20:48:24.329: DEBUG/AndroidRuntime(11805): setted sales_code = XEN
09-06 20:48:24.334: DEBUG/AndroidRuntime(11805): found sales_code tag = <XEN>, </XEN>
09-06 20:48:24.334: DEBUG/dalvikvm(11805): creating instr width table
09-06 20:48:24.404: DEBUG/LibQmg_native(11805): register_android_app_LibQmg
09-06 20:48:24.409: DEBUG/DeviceEncryption(11805): JNI: register_android_deviceencryption_DeviceEncryptionManager
09-06 20:48:24.430: DEBUG/AndroidRuntime(11805): Calling main entry com.android.commands.pm.Pm
09-06 20:48:24.435: DEBUG/AndroidRuntime(11805): Shutting down VM
09-06 20:48:24.435: DEBUG/dalvikvm(11805): GC_CONCURRENT freed 105K, 69% free 317K/1024K, external 0K/0K, paused 0ms+0ms
09-06 20:48:24.435: DEBUG/dalvikvm(11805): Debugger has detached; object registry had 1 entries
09-06 20:48:24.525: DEBUG/AndroidRuntime(11813): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
09-06 20:48:24.525: DEBUG/AndroidRuntime(11813): CheckJNI is OFF
09-06 20:48:24.525: DEBUG/AndroidRuntime(11813): setted country_code = The Netherlands
09-06 20:48:24.525: DEBUG/AndroidRuntime(11813): setted sales_code = XEN
09-06 20:48:24.525: DEBUG/AndroidRuntime(11813): found sales_code tag = <XEN>, </XEN>
09-06 20:48:24.530: DEBUG/dalvikvm(11813): creating instr width table
09-06 20:48:24.545: INFO/DEBUG(2574): tid 11811 does not exist in pid 11805. ignoring debug request
09-06 20:48:24.595: DEBUG/LibQmg_native(11813): register_android_app_LibQmg
09-06 20:48:24.595: DEBUG/DeviceEncryption(11813): JNI: register_android_deviceencryption_DeviceEncryptionManager
09-06 20:48:24.620: DEBUG/AndroidRuntime(11813): Calling main entry com.android.commands.am.Am
09-06 20:48:24.620: INFO/Process(2786): Sending signal. PID: 11793 SIG: 9
09-06 20:48:24.620: INFO/ActivityManager(2786): Force stopping package com.commonsware.cwac.tlv.demo uid=10111
09-06 20:48:24.630: WARN/InputManagerService(2786): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@40c1d338
09-06 20:48:24.645: DEBUG/AndroidRuntime(11813): Shutting down VM
09-06 20:48:24.645: DEBUG/dalvikvm(11813): GC_CONCURRENT freed 106K, 67% free 345K/1024K, external 0K/0K, paused 0ms+0ms
09-06 20:48:24.645: INFO/ActivityManager(2786): Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.commonsware.cwac.tlv.demo/.TouchListViewDemo } from pid 11813
09-06 20:48:24.650: DEBUG/dalvikvm(11813): Debugger has detached; object registry had 1 entries
09-06 20:48:24.675: INFO/ActivityManager(2786): Start proc com.commonsware.cwac.tlv.demo for activity com.commonsware.cwac.tlv.demo/.TouchListViewDemo: pid=11823 uid=10111 gids={1015}
09-06 20:48:24.700: DEBUG/dalvikvm(11823): Debugger has detached; object registry had 1 entries
09-06 20:48:24.705: WARN/ActivityThread(11823): Application com.commonsware.cwac.tlv.demo is waiting for the debugger on port 8100...
09-06 20:48:24.710: INFO/System.out(11823): Sending WAIT chunk
09-06 20:48:24.760: INFO/DEBUG(2574): tid 11819 does not exist in pid 11813. ignoring debug request
09-06 20:48:25.205: WARN/ActivityManager(2786): Activity pause timeout for HistoryRecord{40c0b380 com.commonsware.cwac.tlv.demo/.TouchListViewDemo}
09-06 20:48:25.734: INFO/dalvikvm(11823): Debugger is active
09-06 20:48:25.919: INFO/System.out(11823): Debugger has connected
09-06 20:48:25.919: INFO/System.out(11823): waiting for debugger to settle...
09-06 20:48:26.120: INFO/System.out(11823): waiting for debugger to settle...
09-06 20:48:26.324: INFO/System.out(11823): waiting for debugger to settle...
09-06 20:48:26.524: INFO/System.out(11823): waiting for debugger to settle...
09-06 20:48:26.724: INFO/System.out(11823): waiting for debugger to settle...
09-06 20:48:26.930: INFO/System.out(11823): waiting for debugger to settle...
09-06 20:48:27.130: INFO/System.out(11823): waiting for debugger to settle...
09-06 20:48:27.324: INFO/System.out(11823): waiting for debugger to settle...
09-06 20:48:27.530: INFO/System.out(11823): waiting for debugger to settle...
09-06 20:48:27.729: INFO/System.out(11823): waiting for debugger to settle...
09-06 20:48:27.930: INFO/System.out(11823): debugger has settled (1398)
09-06 20:48:28.445: DEBUG/gps_sirf(2786): sirf_gps_inject_location: called
09-06 20:48:28.505: INFO/wpa_supplicant(24796): SCAN_RESULTS : [5]
09-06 20:48:30.100: VERBOSE/WifiMonitor(2786): Event [ SCAN-RESULTS ]
09-06 20:48:30.105: INFO/wpa_supplicant(24796): SCAN_RESULTS : [5]
09-06 20:48:30.120: INFO/wpa_supplicant(24796): SCAN_RESULTS : [5]
09-06 20:48:30.134: DEBUG/gps_sirf(2786): sirf_gps_inject_location: called
09-06 20:48:30.160: INFO/wpa_supplicant(24796): SCAN_RESULTS : [5]
我没有看到任何错误,而调用堆栈显示:线程挂起(异常runtimeException))
但这似乎很可疑:
09-06 20:48:24.545:INFO/DEBUG(2574):tid 11811 不存在于 pid 11805 中。忽略调试请求
当选择要调试的设备时,对于我的手机,“调试”字段为空对于 1.6 模拟器显示“yes”
When I do something like this:
try{
row=inflater.inflate(R.layout.row2, parent, false);
}catch(Exception e){
Log.e(TAG,"error",e);
}
I get a stacktrace like expected in LogCat.
Without it however, the error is uncaught, but I still expect a trace in the unfiltered Log. But why isn't there? Without it, I see only an exeption state in the "Debug" tab (call stack?) There are places where a try..catch cannot be used, for example in an xml file.
Right now Im facing a runtime exception. The unfiltered log is this:
09-06 20:48:22.760: DEBUG/dalvikvm(11430): GC_EXPLICIT freed 100K, 51% free 2658K/5379K, external 0K/0K, paused 97ms
09-06 20:48:24.329: DEBUG/AndroidRuntime(11805): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
09-06 20:48:24.329: DEBUG/AndroidRuntime(11805): CheckJNI is OFF
09-06 20:48:24.329: DEBUG/AndroidRuntime(11805): setted country_code = The Netherlands
09-06 20:48:24.329: DEBUG/AndroidRuntime(11805): setted sales_code = XEN
09-06 20:48:24.334: DEBUG/AndroidRuntime(11805): found sales_code tag = <XEN>, </XEN>
09-06 20:48:24.334: DEBUG/dalvikvm(11805): creating instr width table
09-06 20:48:24.404: DEBUG/LibQmg_native(11805): register_android_app_LibQmg
09-06 20:48:24.409: DEBUG/DeviceEncryption(11805): JNI: register_android_deviceencryption_DeviceEncryptionManager
09-06 20:48:24.430: DEBUG/AndroidRuntime(11805): Calling main entry com.android.commands.pm.Pm
09-06 20:48:24.435: DEBUG/AndroidRuntime(11805): Shutting down VM
09-06 20:48:24.435: DEBUG/dalvikvm(11805): GC_CONCURRENT freed 105K, 69% free 317K/1024K, external 0K/0K, paused 0ms+0ms
09-06 20:48:24.435: DEBUG/dalvikvm(11805): Debugger has detached; object registry had 1 entries
09-06 20:48:24.525: DEBUG/AndroidRuntime(11813): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
09-06 20:48:24.525: DEBUG/AndroidRuntime(11813): CheckJNI is OFF
09-06 20:48:24.525: DEBUG/AndroidRuntime(11813): setted country_code = The Netherlands
09-06 20:48:24.525: DEBUG/AndroidRuntime(11813): setted sales_code = XEN
09-06 20:48:24.525: DEBUG/AndroidRuntime(11813): found sales_code tag = <XEN>, </XEN>
09-06 20:48:24.530: DEBUG/dalvikvm(11813): creating instr width table
09-06 20:48:24.545: INFO/DEBUG(2574): tid 11811 does not exist in pid 11805. ignoring debug request
09-06 20:48:24.595: DEBUG/LibQmg_native(11813): register_android_app_LibQmg
09-06 20:48:24.595: DEBUG/DeviceEncryption(11813): JNI: register_android_deviceencryption_DeviceEncryptionManager
09-06 20:48:24.620: DEBUG/AndroidRuntime(11813): Calling main entry com.android.commands.am.Am
09-06 20:48:24.620: INFO/Process(2786): Sending signal. PID: 11793 SIG: 9
09-06 20:48:24.620: INFO/ActivityManager(2786): Force stopping package com.commonsware.cwac.tlv.demo uid=10111
09-06 20:48:24.630: WARN/InputManagerService(2786): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@40c1d338
09-06 20:48:24.645: DEBUG/AndroidRuntime(11813): Shutting down VM
09-06 20:48:24.645: DEBUG/dalvikvm(11813): GC_CONCURRENT freed 106K, 67% free 345K/1024K, external 0K/0K, paused 0ms+0ms
09-06 20:48:24.645: INFO/ActivityManager(2786): Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.commonsware.cwac.tlv.demo/.TouchListViewDemo } from pid 11813
09-06 20:48:24.650: DEBUG/dalvikvm(11813): Debugger has detached; object registry had 1 entries
09-06 20:48:24.675: INFO/ActivityManager(2786): Start proc com.commonsware.cwac.tlv.demo for activity com.commonsware.cwac.tlv.demo/.TouchListViewDemo: pid=11823 uid=10111 gids={1015}
09-06 20:48:24.700: DEBUG/dalvikvm(11823): Debugger has detached; object registry had 1 entries
09-06 20:48:24.705: WARN/ActivityThread(11823): Application com.commonsware.cwac.tlv.demo is waiting for the debugger on port 8100...
09-06 20:48:24.710: INFO/System.out(11823): Sending WAIT chunk
09-06 20:48:24.760: INFO/DEBUG(2574): tid 11819 does not exist in pid 11813. ignoring debug request
09-06 20:48:25.205: WARN/ActivityManager(2786): Activity pause timeout for HistoryRecord{40c0b380 com.commonsware.cwac.tlv.demo/.TouchListViewDemo}
09-06 20:48:25.734: INFO/dalvikvm(11823): Debugger is active
09-06 20:48:25.919: INFO/System.out(11823): Debugger has connected
09-06 20:48:25.919: INFO/System.out(11823): waiting for debugger to settle...
09-06 20:48:26.120: INFO/System.out(11823): waiting for debugger to settle...
09-06 20:48:26.324: INFO/System.out(11823): waiting for debugger to settle...
09-06 20:48:26.524: INFO/System.out(11823): waiting for debugger to settle...
09-06 20:48:26.724: INFO/System.out(11823): waiting for debugger to settle...
09-06 20:48:26.930: INFO/System.out(11823): waiting for debugger to settle...
09-06 20:48:27.130: INFO/System.out(11823): waiting for debugger to settle...
09-06 20:48:27.324: INFO/System.out(11823): waiting for debugger to settle...
09-06 20:48:27.530: INFO/System.out(11823): waiting for debugger to settle...
09-06 20:48:27.729: INFO/System.out(11823): waiting for debugger to settle...
09-06 20:48:27.930: INFO/System.out(11823): debugger has settled (1398)
09-06 20:48:28.445: DEBUG/gps_sirf(2786): sirf_gps_inject_location: called
09-06 20:48:28.505: INFO/wpa_supplicant(24796): SCAN_RESULTS : [5]
09-06 20:48:30.100: VERBOSE/WifiMonitor(2786): Event [ SCAN-RESULTS ]
09-06 20:48:30.105: INFO/wpa_supplicant(24796): SCAN_RESULTS : [5]
09-06 20:48:30.120: INFO/wpa_supplicant(24796): SCAN_RESULTS : [5]
09-06 20:48:30.134: DEBUG/gps_sirf(2786): sirf_gps_inject_location: called
09-06 20:48:30.160: INFO/wpa_supplicant(24796): SCAN_RESULTS : [5]
I don't see any errors there, while the call stack shows: thread suspended (exception runtimeException))
This seems suspicious however:
09-06 20:48:24.545: INFO/DEBUG(2574): tid 11811 does not exist in pid 11805. ignoring debug request
When selecting the device to Debug on, the field "Debug" is empty for my phone it shows "yes" for an 1.6 emulator
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果此代码抛出异常,并且代码中的任何位置都没有异常处理,那么您肯定会在 logcat 中看到它。
If this code throws an exception and there is no exception handling anywhere in your code you would definitely see it in the logcat.
问题是调试器在打印堆栈跟踪之前因异常而停止。因此,您所要做的就是按调试面板中的恢复按钮(看起来像 i> )几次,跟踪就会被打印出来。当您在设备上看到强制关闭对话框时,跟踪必须位于 LogCat 中。
The problem was that the debugger halted on the exception, before the stacktrace was printed. So all you have to do is press the resume button(looking like i> ) in the debug panel a few times and the trace will be printed. When you see the force close dialog on your device, the trace must be in LogCat.