在 Eclipse 上为 Android 程序插入断点

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1535915/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 03:13:29  来源:igfitidea点击:

Inserting breakpoints on Eclipse for an Android program

androideclipsedebugging

提问by Amarghosh

I'm using Eclipse 3.3 and Android 1.6. I installed DDMS on my Eclipse and tried to insert breakpoints as in tutorial https://www.ibm.com/developerworks/library/os-ecbug/. However, as I run my project, the program won't stop when it reaches the breakpoint. Is there a bug in Eclipse or am I doing something wrong?

我使用的是 Eclipse 3.3 和 Android 1.6。我在 Eclipse 上安装了 DDMS 并尝试像教程https://www.ibm.com/developerworks/library/os-ecbug/ 中那样插入断点。但是,当我运行我的项目时,程序在到达断点时不会停止。Eclipse 中是否存在错误或我做错了什么?

采纳答案by VonC

To add to Amarghosh answer's, check also your JDK version.

要添加到Amarghosh 的答案,还请检查您的 JDK 版本。

There is a bug with JDK6_u14 et u15, which made your breakpoints "invisible" (the program would not stop during a debug session)
Fixed in the latest one JDK6u16.

JDK6_u14 和 u15存在一个错误,它使您的断点“不可见”(程序不会在调试会话期间停止)
在最新的 JDK6u16 中已修复。

回答by Amarghosh

May be this is the problem:

可能是这个问题:

However, as I run my project

但是,当我运行我的项目时

Debug the project instead of running it. Select 'Debug' from the 'Run' menu or hit F11.

调试项目而不是运行它。从“运行”菜单中选择“调试”或按 F11。

回答by Shakil78692

If the breakpoint symbol/circle has a line going through it, it means you have the "skip all breakpoints" option selected. You can de-select it in the Debug view, under the "Breakpoints" section/box.

如果断点符号/圆圈有一条线穿过它,则意味着您选择了“跳过所有断点”选项。您可以在“调试”视图中的“断点”部分/框下取消选择它。

回答by Scott

My breakpoints haven't been working either. In my debug configuration on the Android tab, I had the launch action set to "Do Nothing". When I changed that to instead launch directly into an activity, my breakpoints started working.

我的断点也没有用。在 Android 选项卡上的调试配置中,我将启动操作设置为“什么都不做”。当我将其更改为直接启动一个活动时,我的断点开始工作。

回答by AshleyJ

If you're trying to debug a service or widget you'll need to start an activity in order for the debugger to attach properly.

如果您正在尝试调试服务或小部件,您需要启动一个活动,以便调试器正确连接。