android 调试器不会在断点处停止

发布于 2024-10-21 11:31:09 字数 70 浏览 7 评论 0原文

我在控制台中看到调试语句,但调试器不会在任何断点处停止。我尝试清除所有断点并将它们添加回来。不确定这是如何发生的,但确实如此。

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(14

追我者格杀勿论 2024-10-28 11:31:09

对我有用的解决方案:

  • 只需从设备卸载应用在设备上手动)并尝试调试再次(!)

Solution that worked for me:

  • Simply uninstall the app from the device (manually on the device) and try debugging again(!)
素衣风尘叹 2024-10-28 11:31:09

如果您使用 Android studio,请单击 debug app 而不是 run app

在此输入图像描述

If you use Android studio, click debug app instead of run app:

enter image description here

妄断弥空 2024-10-28 11:31:09

根据 这个答案,在您的应用程序模块的 build.gradle 内,为您的构建禁用 minifyEnable变体并将其更改为 false。那么,它应该是:

minifyEnabled 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:

minifyEnabled false

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

晨曦÷微暖 2024-10-28 11:31:09

您是否在 AndroidManifest 中设置了可调试标志?
如果您错过了这一点,请在应用程序标记中添加 android:debuggable="true" 。
最后应该是这样的:

<application android:icon="@drawable/icon" android:label="@string/app_name" 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:

<application android:icon="@drawable/icon" android:label="@string/app_name" android:debuggable="true">
对不⑦ 2024-10-28 11:31:09

就我而言,单击“将调试器附加到 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.

过去的过去 2024-10-28 11:31:09

对于 Android Studio:

  • 检查选项 Mute Breakpoints 是否被错误启用。图标如下所示:

Android 调试工具栏

对于 Eclipse:

  • 检查选项“跳过所有断点”被错误启用。它是以下工具栏上的最后一个图标 skip-all icon

eclipse 工具栏

For Android Studio:

  • Check if the option Mute Breakpoints is enabled by mistake. The icon looks like this:

Android debug toolbar

For Eclipse:

  • Check if the option "Skip All Breakpoints" is enabled by mistake. It is the last icon on the following toolbar skip-all icon

eclipse toolbar

浅听莫相离 2024-10-28 11:31:09

您是否执行了“调试为 --> Android 应用程序”而不是“运行为”?

仅当您执行“调试为”时,Eclipse 才会在断点处停止。

Did you do "Debug As --> Android Application" instead of "Run As"?

Only if you do "Debug As", eclipse will stop at breakpoints.

帅气称霸 2024-10-28 11:31:09

我也有同样的问题。
转到 build.gradle。
如果您有此代码,则必须更改此代码。

buildTypes {
    release {
        minifyEnabled true
        shrinkResources true
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    }
    debug {
        debuggable true
        minifyEnabled true
        shrinkResources true
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    }
}

调试部分应如下所示:

buildTypes {
    release {
        minifyEnabled false
        shrinkResources false
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    }
    debug {
        debuggable true
        minifyEnabled false
        shrinkResources false
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    }
}

我希望您的问题得到解决

I had the same problem.
Go to build.gradle.
You must change this code if you have one.

buildTypes {
    release {
        minifyEnabled true
        shrinkResources true
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    }
    debug {
        debuggable true
        minifyEnabled true
        shrinkResources true
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    }
}

The debug section should look like this:

buildTypes {
    release {
        minifyEnabled false
        shrinkResources false
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    }
    debug {
        debuggable true
        minifyEnabled false
        shrinkResources false
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    }
}

I hope your problem is solved

眼泪淡了忧伤 2024-10-28 11:31:09

就我而言,应用程序使用 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 add android.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.

请止步禁区 2024-10-28 11:31:09

如果您在 build.gradle 中添加了一些构建类型,请检查是否具有debuggable true

buildTypes {
    debug {
        debuggable true
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    } 

    release {
        minifyEnabled true
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    }
}

if you have added some build type in build.gradle check to have debuggable true

buildTypes {
    debug {
        debuggable true
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    } 

    release {
        minifyEnabled true
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    }
}
小伙你站住 2024-10-28 11:31:09

我遇到了这个问题,我清理了 build.gradle 的 buildTypes 部分
并尝试年龄,这样它对我有用。

i had this problem i clean buildTypes part of build.gradle
and try age so it work me.

≈。彩虹 2024-10-28 11:31:09

如果您在使用 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

谢绝鈎搭 2024-10-28 11:31:09

上面的有效答案都不适合我。就我而言,另一个应用程序仍在后台运行,该应用程序是我早些时候通过 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.

晨与橙与城 2024-10-28 11:31:09

我遇到了同样的问题,并通过增加调试器超时值来解决它。
模拟器在我的开发盒上慢得像狗,这就是阻止调试器捕获并在断点处停止的原因。
我将超时值分别从 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文