android 调试器不会在断点处停止
我在控制台中看到调试语句,但调试器不会在任何断点处停止。我尝试清除所有断点并将它们添加回来。不确定这是如何发生的,但确实如此。
I am seeing debug statements in the console but the debugger does not stop on any breakpoints. I tried clearing all breakpoints and adding them back in. Not sure how this can happen but it is.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(14)
对我有用的解决方案:
Solution that worked for me:
如果您使用 Android studio,请单击
debug app
而不是run app
:If you use Android studio, click
debug app
instead ofrun app
:根据 这个答案,在您的应用程序模块的
build.gradle
内,为您的构建禁用 minifyEnable变体并将其更改为 false。那么,它应该是:否则,当您将鼠标悬停在断点标记上时,您将看到
Line number not available in class xxxx
,并且它们上会带有十字According to this answer, Inside
build.gradle
for your app module, disable minifyEnable for your build variant and change it to false. Then, it should be:othewise you will see
Line number not available in class xxxx
when you hover over breakpoint markers and they will be looked with a cross on them您是否在 AndroidManifest 中设置了可调试标志?
如果您错过了这一点,请在应用程序标记中添加 android:debuggable="true" 。
最后应该是这样的:
Have you set the debuggable flag in the AndroidManifest?
If you miss that, do so by adding android:debuggable="true" in the application tag.
It should look like that in the end:
就我而言,单击“将调试器附加到 Android 进程”
它将显示一个窗口,显示“选择进程”
选择您正在使用的设备,然后选择您要调试的项目。它有效。
有时,当您第一次打开调试器时,调试器需要重新连接到设备。
In my case, click the "Attach debugger to Android process"
And it will shows a window said "Choose Process"
Select the device you are using, and select the project that you want to debug. And it works.
Sometimes the debugger need to re-attach to the devices when you open the debugger at the first time.
对于 Android Studio:
Mute Breakpoints
是否被错误启用。图标如下所示:对于 Eclipse:
For Android Studio:
Mute Breakpoints
is enabled by mistake. The icon looks like this:For Eclipse:
您是否执行了“调试为 --> Android 应用程序”而不是“运行为”?
仅当您执行“调试为”时,Eclipse 才会在断点处停止。
Did you do "Debug As --> Android Application" instead of "Run As"?
Only if you do "Debug As", eclipse will stop at breakpoints.
我也有同样的问题。
转到 build.gradle。
如果您有此代码,则必须更改此代码。
调试部分应如下所示:
我希望您的问题得到解决
I had the same problem.
Go to build.gradle.
You must change this code if you have one.
The debug section should look like this:
I hope your problem is solved
就我而言,应用程序使用 AndroidManifest 中的
android:process=":service"
创建了一个具有不同进程的服务。因此,我在服务进程代码中设置断点,同时调试器自动附加到主应用程序进程。我很愚蠢,但它可能对其他人有帮助。您可以使用
Run > 附加到服务进程。将调试器附加到 Android 进程
并选择服务进程。如果您无法及时手动附加,您可能需要将android.os.Debug.waitForDebugger();
添加到您的服务进程代码中。据我所知,没有办法在运行之前自动告诉 Android Studio 或 IntelliJ 连接到不同的进程。
In my case, the app created a service with a different process with
android:process=":service"
in the AndroidManifest. So I was setting breakpoints in the service process code while the debugger is automatically attached to the main app process. Pretty stupid of me but it might help someone else.You attach to the service process with
Run > Attach Debugger To Android Process
and choose the service process. You might need to addandroid.os.Debug.waitForDebugger();
to your service process code if you can't attach in time manually.As far as I know, there's no way to automatically tell Android Studio or IntelliJ to attach to a different process before running.
如果您在
build.gradle
中添加了一些构建类型
,请检查是否具有debuggable true
if you have added some
build type
inbuild.gradle
check to havedebuggable true
我遇到了这个问题,我清理了 build.gradle 的 buildTypes 部分
并尝试年龄,这样它对我有用。
i had this problem i clean buildTypes part of build.gradle
and try age so it work me.
如果您在使用 Flutter 插件时发现此问题,可以尝试将插件更新到 这篇文章
If you are finding this issue while using the Flutter plugin, you can try updating the plugin to version >65.1.3 as specified in this article
上面的有效答案都不适合我。就我而言,另一个应用程序仍在后台运行,该应用程序是我早些时候通过 Android Studio 启动的。所以不是同一个 App/PackageId,而是另一个。关闭该应用程序后,我通过 wifi 调试命中了断点。
None of the valid answers above worked for me. In my case there was another app still in the background that I had launched some time earlier via Android Studio. So not the same App/PackageId, but another. After closing that app I got hits on breakpoints via wifi debugging.
我遇到了同样的问题,并通过增加调试器超时值来解决它。
模拟器在我的开发盒上慢得像狗,这就是阻止调试器捕获并在断点处停止的原因。
我将超时值分别从 3000 更改为 10000 和 20000 更改为 60000,现在一切正常。
五、
I had the same issue and resolved it by increasing the debugger timeout values.
The emulator is slow as a dog on my Dev box and that is what prevented the debugger to catch and stop on breakpoints.
I changed the timeout values respectively from 3000 to 10000 and 20000 to 60000 and all is fine now.
V.