Android调试与Eclipse -没有断点

时间:2022-04-17 11:16:16

I am trying to debug a simple Android application on either the emultor or a device and I cannot get the debugger to stop on any breakpoints I have set. I have combined the other posts here and throughout the web and tried all the suggestions (Add debuggable:"true" to the manifest, stop and start adb, Clean all, make sure I use the debug button not the run button, etc etc). In the Debug perspective I can see the threads and in DDMS it shows the debug icon next to the device I am debugging on. I do see the blue dots where I set the breakpoint and the Debug perspective lists them and says they are active.

我在调试一个简单的Android应用程序emultor或设备上,我不能让调试器停止在任何断点设置。我这里有结合其他岗位和整个网络,所有的建议(添加debuggable:“真正的”清单,停止和启动亚行,清洁,确保我使用debug按钮没有run按钮,等等)。在Debug透视图中,我可以看到线程,在DDMS中,在我正在调试的设备旁边显示调试图标。我确实看到了设置断点的蓝点,调试透视图列出了它们,并说它们是活动的。

I have put in alerts just before the breakpoints to verify the code is getting executed.

我在断点之前放入了警报,以验证代码正在执行。

Starting to go crazy here. Any other suggestions? I must be missing something simple but non-obvious.

开始疯狂了。还有其他的建议吗?我一定错过了一些简单但不明显的东西。

UPDATE: I appreciate the responses so far. Unfortunately they have not solved my problem. I have followed the instruction on debugging and have debugging turned on in the phone. Also, I do see the "Waiting for debugger" alert on the phone when starting. In general everything says I am debugging (including getting logcat output that I have added). It just will not stop on breakpoints that I have added and are listed in the breakpoints tab in the Debug perspective. Also just to reiterate - this happens when debugging on the device as well as on the emulator. One thing I do notice is that when I launch the debugger I have it set to bring up the Android Device Chooser. In there the "debug" column is blank for my device - but if the emulator is running the debug column does say 'Yes'. Also the console states that is attempting to connect to the debugger. Should there be a console log that states that the debugger successfully connected? I do not see this.

更新:我很感激到目前为止的回复。不幸的是他们没有解决我的问题。我在电话中遵循了调试和调试的指令。此外,我确实看到“等待调试器”警报在电话上启动。一般来说,一切都说我正在调试(包括我添加的logcat输出)。它不会停留在我添加的断点上,并在Debug透视图的breakpoints选项卡中列出。还要重申一下——在设备和模拟器上调试时都会发生这种情况。我注意到的一件事是,当我启动调试器时,我将它设置为打开Android设备选择器。在那里,“debug”列是我的设备的空白—但是如果仿真器正在运行调试列,那么它会说“Yes”。控制台还声明正在尝试连接到调试器。是否应该有一个控制台日志声明调试器已成功连接?我没看到这个。

UPDATE 20120914: I have been away from this for some time and had given up previously. Back to try and tackle this. It is still not resolved. Everything above is still current - but one other thing I have noticed. I set a Class Load Breakpoint on the main activity and it does stop there. It just does not stop at any Line Breakpoints. I have just updated to the latest JDK 1.7.0_07, Android SDK 20, ADT Plugin 20.0.3. I have used the logcat to output a message and set a breakpoint on this line. I see the message in logcat so I know the code is being executed. The debug window in the debig perspective also does show the android application with a number of threads beneath it and the Devices window in the DDMS perspective shows the application with the green bug icon next to it.

更新20120914:我已经离开这段时间了,之前已经放弃了。回来尝试解决这个问题。它仍然没有得到解决。上面的一切仍然是最新的——但我注意到另一件事。我在主活动上设置了一个类加载断点,它在这里停止。它不会在任何线断点处停止。我刚刚更新了最新的JDK 1.7.0_07, Android SDK 20, ADT插件20.0.3。我使用logcat输出一条消息,并在这一行上设置断点。我在logcat中看到消息,所以我知道代码正在执行。debig透视图中的调试窗口也显示了android应用程序,在它下面有许多线程,而DDMS透视图中的设备窗口则显示了应用程序与它旁边的绿色bug图标。

One more thing - when the debugger is running the line breakpoints bullets do not get a checkmark overlaid on them (the Class Load Breakpoint does!). I am guessing this is the root cause - but I don't know why they are not getting this. (By the way skip breakoints is also not set - breakpoints do not have lines through them).

还有一件事——当调试器运行线断点子弹时,不会得到一个覆盖在上面的复选标记(类装载断点会得到!)我猜这是根本原因——但我不知道他们为什么得不到这个。(顺便说一下,跳过断点也不设置——断点没有通过它们的行)。

Any new suggestions would be appreciated. I have burned a lot of time on this. It must be something obvious that I am not seeing.

如有新的建议,我们将不胜感激。我在这上面花了很多时间。这一定是我没有看到的明显的东西。

6 个解决方案

#1


5  

Now I feel a bit stupid writing this post. But I resolved my issue finally. The problem is you cannot set breakpoints in the Javascript code. The part I left out unintentionally is I am writing an app for Android using PhoneGap. Almost all the code is Javascript. I am so used to developing .NET web apps in Visual Studio I just assumed you could set breakpoints in the javascript code. Breakpoints in the Java code happen to work fine. Anyway, Thanks for any suggestions. Do';t know if there are other .NET developers trying PhoneGap development - but maybe this post will help them.

现在我觉得写这篇文章有点傻。但我最终解决了我的问题。问题是您不能在Javascript代码中设置断点。我无意中漏掉的部分是,我正在用PhoneGap为Android编写一个应用程序。几乎所有的代码都是Javascript。我非常习惯于在Visual Studio中开发。net web应用程序,我只是假设您可以在javascript代码中设置断点。Java代码中的断点碰巧工作得很好。不管怎样,谢谢你的建议。我不知道是否有其他。net开发人员正在尝试PhoneGap开发,但这篇文章可能会对他们有所帮助。

#2


3  

Android SDK provides most of the tools that you need to debug your applications. This link will introduce you to Android debugging environment and the debugging tools used.

Android SDK提供了调试应用程序所需的大多数工具。这个链接将向您介绍Android调试环境和使用的调试工具。

Here's also a hands on tutorial on debugging an android application.

这里还有一个关于调试android应用程序的教程。

If you want to debug using actual android phone, turn on "USB Debugging" in your device:

如果您想要使用实际的android手机进行调试,请打开设备中的“USB调试”:

Settings > Applications > Development and enable USB debugging

设置>应用>开发和启用USB调试。

Android 4.0:

Android 4.0:

Settings > Developer options

设置>开发人员选项

AND make use of Log.d and your Logcat.

利用对数。d和Logcat。

#3


1  

Eclipse has a debug run configuration. Only if you use the debug run configuration will a debugger be attached with the application during launch.

Eclipse有一个调试运行配置。只有在使用调试运行配置时,才会在启动时将调试器附加到应用程序中。

Does the application launch (on the device/emulator) pause a while "Waiting for Debugger" ? If not, then you are not launching the application using "debug configuration". Its the button to the immediate left of run (drop down) configuration.

应用程序启动(在设备/模拟器上)会暂停片刻“等待调试器”吗?如果不是,那么您就没有使用“调试配置”启动应用程序。它是run(下拉)配置的最左边的按钮。

#4


1  

Try jsHybugger: http://www.jshybugger.org/ for setting javascript breakpoints in Eclipse for remote(mobile) devices.

尝试jsHybugger: http://www.jshybugger.org/在Eclipse中为远程(移动)设备设置javascript断点。

It lets you set breakpoints, singlestep, catch exceptions, and interact with the JS/DOM environment. You can use it from Eclipse or from a Chrome or Chrome-compatible debugger on the remote desktop. It can be used with apps that create their own webView.

它允许您设置断点、单步、捕获异常,并与JS/DOM环境交互。您可以从Eclipse或远程桌面上的Chrome或兼容Chrome的调试器中使用它。它可以与创建自己webView的应用一起使用。

However, you have to install a few files -- but probably no more complicated to use than weinre. it does extensively modify the JS files (on the fly, transparently to the user) to enable all this debugging -- webKit really should support javascript debugging natively.

不过,您必须安装一些文件——但使用起来可能并不比weinre复杂。它广泛地修改了JS文件(动态地,对用户透明地)以启用所有这些调试——webKit确实应该支持javascript本地调试。

#5


0  

Make sure you did not check skip all breakpoints (Run -> Skip all breakpoints).

确保您没有检查跳过所有断点(运行->跳过所有断点)。

#6


0  

Ribo already mentions it in his answer, but since this question and answers are about debugging Phonegap applications. You certainly have to look at weinre (WEb INspector REmote). http://people.apache.org/~pmuellr/weinre/docs/latest/

Ribo已经在他的回答中提到了这个问题,但是由于这个问题和答案是关于调试Phonegap应用程序的。你一定要看看weinre (WEb INspector REmote)。http://people.apache.org/ pmuellr最新/ weinre / docs / /

Nowadays phonegap even has it's own weinre embraced in phonegap build... http://debug.phonegap.com/

如今,phonegap甚至在phonegap构建中拥有自己的weinre…http://debug.phonegap.com/

I Am a big fan of this... (note if you are using weinre on your local machine and trying to debug a phonegap app via wifi... make sure your local device is on the same wifi network!)

我是这个的超级粉丝……(注意,如果您正在本地机器上使用weinre,并试图通过wifi调试phonegap应用程序……)确保你的本地设备在同一个wifi网络上!

#1


5  

Now I feel a bit stupid writing this post. But I resolved my issue finally. The problem is you cannot set breakpoints in the Javascript code. The part I left out unintentionally is I am writing an app for Android using PhoneGap. Almost all the code is Javascript. I am so used to developing .NET web apps in Visual Studio I just assumed you could set breakpoints in the javascript code. Breakpoints in the Java code happen to work fine. Anyway, Thanks for any suggestions. Do';t know if there are other .NET developers trying PhoneGap development - but maybe this post will help them.

现在我觉得写这篇文章有点傻。但我最终解决了我的问题。问题是您不能在Javascript代码中设置断点。我无意中漏掉的部分是,我正在用PhoneGap为Android编写一个应用程序。几乎所有的代码都是Javascript。我非常习惯于在Visual Studio中开发。net web应用程序,我只是假设您可以在javascript代码中设置断点。Java代码中的断点碰巧工作得很好。不管怎样,谢谢你的建议。我不知道是否有其他。net开发人员正在尝试PhoneGap开发,但这篇文章可能会对他们有所帮助。

#2


3  

Android SDK provides most of the tools that you need to debug your applications. This link will introduce you to Android debugging environment and the debugging tools used.

Android SDK提供了调试应用程序所需的大多数工具。这个链接将向您介绍Android调试环境和使用的调试工具。

Here's also a hands on tutorial on debugging an android application.

这里还有一个关于调试android应用程序的教程。

If you want to debug using actual android phone, turn on "USB Debugging" in your device:

如果您想要使用实际的android手机进行调试,请打开设备中的“USB调试”:

Settings > Applications > Development and enable USB debugging

设置>应用>开发和启用USB调试。

Android 4.0:

Android 4.0:

Settings > Developer options

设置>开发人员选项

AND make use of Log.d and your Logcat.

利用对数。d和Logcat。

#3


1  

Eclipse has a debug run configuration. Only if you use the debug run configuration will a debugger be attached with the application during launch.

Eclipse有一个调试运行配置。只有在使用调试运行配置时,才会在启动时将调试器附加到应用程序中。

Does the application launch (on the device/emulator) pause a while "Waiting for Debugger" ? If not, then you are not launching the application using "debug configuration". Its the button to the immediate left of run (drop down) configuration.

应用程序启动(在设备/模拟器上)会暂停片刻“等待调试器”吗?如果不是,那么您就没有使用“调试配置”启动应用程序。它是run(下拉)配置的最左边的按钮。

#4


1  

Try jsHybugger: http://www.jshybugger.org/ for setting javascript breakpoints in Eclipse for remote(mobile) devices.

尝试jsHybugger: http://www.jshybugger.org/在Eclipse中为远程(移动)设备设置javascript断点。

It lets you set breakpoints, singlestep, catch exceptions, and interact with the JS/DOM environment. You can use it from Eclipse or from a Chrome or Chrome-compatible debugger on the remote desktop. It can be used with apps that create their own webView.

它允许您设置断点、单步、捕获异常,并与JS/DOM环境交互。您可以从Eclipse或远程桌面上的Chrome或兼容Chrome的调试器中使用它。它可以与创建自己webView的应用一起使用。

However, you have to install a few files -- but probably no more complicated to use than weinre. it does extensively modify the JS files (on the fly, transparently to the user) to enable all this debugging -- webKit really should support javascript debugging natively.

不过,您必须安装一些文件——但使用起来可能并不比weinre复杂。它广泛地修改了JS文件(动态地,对用户透明地)以启用所有这些调试——webKit确实应该支持javascript本地调试。

#5


0  

Make sure you did not check skip all breakpoints (Run -> Skip all breakpoints).

确保您没有检查跳过所有断点(运行->跳过所有断点)。

#6


0  

Ribo already mentions it in his answer, but since this question and answers are about debugging Phonegap applications. You certainly have to look at weinre (WEb INspector REmote). http://people.apache.org/~pmuellr/weinre/docs/latest/

Ribo已经在他的回答中提到了这个问题,但是由于这个问题和答案是关于调试Phonegap应用程序的。你一定要看看weinre (WEb INspector REmote)。http://people.apache.org/ pmuellr最新/ weinre / docs / /

Nowadays phonegap even has it's own weinre embraced in phonegap build... http://debug.phonegap.com/

如今,phonegap甚至在phonegap构建中拥有自己的weinre…http://debug.phonegap.com/

I Am a big fan of this... (note if you are using weinre on your local machine and trying to debug a phonegap app via wifi... make sure your local device is on the same wifi network!)

我是这个的超级粉丝……(注意,如果您正在本地机器上使用weinre,并试图通过wifi调试phonegap应用程序……)确保你的本地设备在同一个wifi网络上!