默认情况下启用堆栈跟踪

时间:2011-09-06 16:00:58

标签: android eclipse debugging adb

当我做这样的事情时:

try{
    row=inflater.inflate(R.layout.row2, parent, false);
}catch(Exception e){
    Log.e(TAG,"error",e);
}

我在LogCat中获得了预期的堆栈跟踪。 但是,如果没有它,则错误未被捕获,但我仍然期望未经过滤的Log中存在痕迹。但为什么不存在呢?没有它,我在“Debug”选项卡中看到只有一个exeption状态(调用堆栈?)有些地方不能使用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] 

我没有看到任何错误,而调用堆栈显示:线程挂起(异常运行时异常))

但这似乎很可疑:

09-06 20:48:24.545:INFO / DEBUG(2574):pid 11805中不存在tid 11811.忽略调试请求

当选择要启用Debug的设备时,我的手机的“Debug”字段为空,1.6模拟器显示“是”

2 个答案:

答案 0 :(得分:0)

如果此代码抛出异常并且代码中的任何地方都没有异常处理,那么您肯定会在logcat中看到它。

答案 1 :(得分:0)

问题是调试器在打印堆栈跟踪之前暂停了异常。因此,您只需按几次调试面板中的继续按钮(看起来像我&gt;),即可打印跟踪。当您在设备上看到强制关闭对话框时,跟踪必须在LogCat中。