安卓Eclipse无法调试

19
我的应用程序调试突然出了问题。到目前为止,一切都很好,我甚至重新加载了一个已知良好的完整代码版本,但仍无法进行调试或运行。当我点击调试或运行时,应用程序启动,并在即将显示应用程序时崩溃(甚至没有进入主视图之前)。我在代码的第一行上设置了断点,它永远不会到达那里。它只是进入"Source not found"(未找到源)-“The source attachment does not contain the source for the file DexFile.class ......” 我对加载的所有代码都非常确定,因为它是上次工作时保存的备份。
此外,奇怪的是,如果此时拔掉电缆,应用程序会正常加载并正常工作。所以这绝对是一个调试问题。它在启动时卡在某个地方。我已经多次重启了我的电脑和手机,但都没有效果。
LogCat:
`04-04 11:17:33.462: DEBUG/AndroidRuntime(4148): CheckJNI is OFF
04-04 11:17:33.462: DEBUG/dalvikvm(4148): creating instr width table
04-04 11:17:33.502: DEBUG/AndroidRuntime(4148): --- registering native functions ---
04-04 11:17:33.712: DEBUG/AndroidRuntime(4148): Shutting down VM
04-04 11:17:33.712: DEBUG/dalvikvm(4148): Debugger has detached; object registry had 1 entries
04-04 11:17:33.712: INFO/AndroidRuntime(4148): NOTE: attach of thread 'Binder Thread #3' failed
04-04 11:17:33.902: DEBUG/AndroidRuntime(4157): >>>>>>>>>>>>>> AndroidRuntime START <<<<<<<<<<<<<<
04-04 11:17:33.902: DEBUG/AndroidRuntime(4157): CheckJNI is OFF
04-04 11:17:33.902: DEBUG/dalvikvm(4157): creating instr width table
04-04 11:17:33.942: DEBUG/AndroidRuntime(4157): --- registering native functions ---
04-04 11:17:34.152: INFO/Process(107): Sending signal. PID: 4137 SIG: 9
04-04 11:17:34.152: INFO/ActivityManager(107): Force stopping package org.scanner uid=10110
04-04 11:17:34.162: ERROR/ActivityManager(107): fail to set top app changed!
04-04 11:17:34.182: INFO/UsageStats(107): Unexpected resume of com.htc.launcher while already resumed in org.scanner
04-04 11:17:34.192: INFO/ActivityManager(107): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=org.obdscanner/.activity.ObdReaderMainActivity }
04-04 11:17:34.202: DEBUG/AndroidRuntime(4157): Shutting down VM
04-04 11:17:34.202: DEBUG/dalvikvm(4157): Debugger has detached; object registry had 1 entries
04-04 11:17:34.212: INFO/AndroidRuntime(4157): NOTE: attach of thread 'Binder Thread #3' failed
04-04 11:17:34.222: WARN/InputManagerService(107): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@464105d8
04-04 11:17:34.242: INFO/ActivityManager(107): Start proc org.scanner for activity org.obdscanner/.activity.ReaderMainActivity: pid=4165 uid=10110 gids={3003, 3002}
04-04 11:17:34.332: WARN/ActivityThread(4165): Application org.scanner is waiting for the debugger on port 8100...
04-04 11:17:34.332: INFO/System.out(4165): Sending WAIT chunk
04-04 11:17:34.352: INFO/dalvikvm(4165): Debugger is active
04-04 11:17:34.472: DEBUG/Norton Community Watch/smrsd(3910): smrsd broadcast intent success!
04-04 11:17:34.512: ERROR/(3910): /data/data/com.symantec.monitor/app_log_item/1301930254.txt//data/data/com.symantec.monitor/app_log_item
04-04 11:17:34.542: INFO/System.out(4165): Debugger has connected
04-04 11:17:34.542: INFO/System.out(4165): waiting for debugger to settle...
04-04 11:17:34.632: INFO/global(3898): Default buffer size used in BufferedReader constructor. It would be better to be explicit if an 8k-char buffer is required.
04-04 11:17:34.742: INFO/System.out(4165): waiting for debugger to settle...
04-04 11:17:34.862: DEBUG/dalvikvm(3898): GC_FOR_MALLOC freed 4492 objects / 274560 bytes in 41ms
04-04 11:17:34.942: INFO/System.out(4165): waiting for debugger to settle...
04-04 11:17:35.142: INFO/System.out(4165): waiting for debugger to settle...
04-04 11:17:35.342: INFO/System.out(4165): waiting for debugger to settle...
04-04 11:17:35.552: INFO/System.out(4165): waiting for debugger to settle...
04-04 11:17:35.752: INFO/System.out(4165): waiting for debugger to settle...
04-04 11:17:35.952: INFO/System.out(4165): waiting for debugger to settle...
04-04 11:17:36.157: INFO/System.out(4165): debugger has settled (1451)
04-04 11:17:37.296: DEBUG/dalvikvm(4165): threadid=1: still suspended after undo (sc=1 dc=1 s=Y)

你尝试过清理项目、重启adb或重启eclipse吗? - tbruyelle
11
已解决!奇怪的方法...我刚刚在包资源管理器中关闭了该项目,然后将其从工作区中删除。关闭 Eclipse。重新打开 Eclipse 并导入该项目。现在一切正常。非常奇怪,特别是因为即使重新启动电脑和电话也无法解决问题。令人惊讶的是,仅仅是从包资源管理器中删除应用程序,再重新添加就解决了问题。 - Jesse
18
@Jesse:您是否介意将您的解决方案作为答案发布到您的问题中(您甚至可以稍后接受它),这样a)它不再是未解决的问题,b)其他用户也可以从中学习。 - Heiko Rupp
2
@Jesse 我赞同Heiko的评论。你的解决方案对我很有用,如果没有它,我几乎要离开这个页面了。无论如何,还是谢谢你。 - Nick
@Jesse 我也赞同,当我的 Eclipse 崩溃并陷入混乱时,这个方法非常有效。我差点没看到这个评论。谢谢! - nhunston
显示剩余4条评论
8个回答

11
请查看正确答案 这里

您已在其中一个类中设置断点。只需取消项目中的所有断点并再次运行,就不会出现问题。

Eclipse->Window->Show View->(Other->Debug->)Breakpoints


8

有时Eclipse和各种Android开发插件会失去同步。当调试/开发变得“奇怪”时,我通常尝试以下操作:

  1. If your Logcat is not displaying lines, clear it. It has a small buffer. Also ensure that your device is selected in the "DDMS" perspective. If you have the emulator selected you will only receive logging from it.
  2. Clean and Rebuild all open projects. Ensure there are no errors.
  3. Uninstall the application from the remote device/emulator.
  4. Restart Eclipse!
  5. Open a terminal on your platform and use the tool adb in the "platform-tools" directory.

    adb kill-server
    adb start-server
    
  6. Stash your working copy and revert your source code if using a repository.


4
奇怪的解决方案...我只是从包资源管理器中关闭了项目,然后将其从工作区中删除。关闭Eclipse。重新打开Eclipse并导入该项目。 (Jesse的评论复制并粘贴。)

2
我尝试了以上所有方法,但由于有多个eclipse.exe实例,所以它们都没有起作用。在任务管理器(CTRL+SHIFT+ESC)中将它们全部结束解决了这个问题。

1

在您的Android设备(或模拟器)上,请前往:

Applications - Settings - Applications - Manage applications - All

在那里,您必须选择您的应用并卸载它。

之后再次尝试从IDE运行您的应用程序。现在应该可以正常工作了。


0

我曾经遇到过这种情况,因为我的代码被混淆了。我没有注意到有人在生产发布中更改了proguard.cfg,并注释掉了“-dontobfuscate”行。


0

0

我知道现在有点晚了...如果@Sam或@Killesk的答案不起作用,可以使用它。

  1. 确保清单设置了 android:debuggable

  2. onCreate 中,添加一个调用Debug.waitForDebugger

在反向工程时,将调用 waitForDebugger 也起作用。例如,您可以手动在 onCreate 中添加以下代码,并使 smali/baksmali 重新编译:

invoke-static {}, Landroid/os/Debug;->waitForDebugger()V

我不经常使用这个技巧,但每当我需要时,waitForDebugger 总是有效的。我不记得有过无法使用它来调试的情况。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接