Android 即使不在调试模式下运行,也会显示“等待调试器附加”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10573210/
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 04:12:23  来源:igfitidea点击:

"Waiting for debugger to attach" showing even when not running in debug mode

androiddebugging

提问by Raul Rene

My problem:

我的问题

I ran upon an awkward problem as I was developing my application. As mentioned in the title, every time I install my application (in run mode, not debug!) at start-up the waiting for debugger to connect..message appears for 1-2-3 seconds, and the application starts.

我在开发应用程序时遇到了一个尴尬的问题。正如标题中提到的,每次我在启动时安装我的应用程序(在运行模式下,而不是调试!)时,等待调试器连接..消息会出现 1-2-3 秒,然后应用程序启动。

What I want:

我想要什么

What I would like is to be able to start the application without that message appearing (it only started appearing in the last few days, and I can't remember changing anything related to debugging).

我想要的是能够在不出现该消息的情况下启动应用程序(它仅在最近几天开始出现,我不记得更改与调试相关的任何内容)。

What I've tried:

我试过的

  • I have tried setting the android:debuggable="false"but if I do this the debugger never attaches and the message never disappears.
  • I have also tried after installing to disable USB Debugging, but still no results.
  • Even if I kill the application and wake it up through an external source (it uses Google's C2D Messaging Framework) it still tries to run in debug mode on wake-up.
  • 我试过设置,android:debuggable="false"但如果我这样做,调试器永远不会附加并且消息永远不会消失。
  • 我也试过安装后禁用USB Debugging,但仍然没有结果。
  • 即使我终止应用程序并通过外部源(它使用 Google 的 C2D 消息传递框架)将其唤醒,它仍会尝试在唤醒时以调试模式运行。

I have developed several Android applications and never stumbled upon this. Why wouldn't I be able to start the application in RUN mode? Is there any other way to install the application on the device, without hitting the run button in Eclipse?

我开发了几个 Android 应用程序,但从未偶然发现过。为什么我不能在 RUN 模式下启动应用程序?有没有其他方法可以在设备上安装应用程序,而无需在 Eclipse 中点击运行按钮?

I can post code-snippets from the AndroidManifest or from other parts of the code if necessary, but as I already mentioned I wasn't getting this kind of weird behavior several days ago.

如有必要,我可以从 AndroidManifest 或代码的其他部分发布代码片段,但正如我已经提到的,几天前我没有遇到这种奇怪的行为。

回答by Akram

Make sure your java files dont have any break point and Restart the deviceevery thing should be normal.

确保你的 java 文件没有任何断点,Restart the device一切都应该正常。

I was experience the same problems where my application was always being run in debug mode. Restarting the device did the trick for me.

我遇到了同样的问题,我的应用程序总是在调试模式下运行。重新启动设备对我有用。

and make sure you are using

并确保您正在使用

right click on project-->>Run As -->> Android Application

右键单击项目-->>运行方式-->> Android 应用程序

回答by user2757848

I had the same problem using Android Studio. Restarting my cellphone worked for me!

我在使用 Android Studio 时遇到了同样的问题。重启我的手机对我有用!

回答by Enrichman

For me the solution was turning off the USB debuggingfrom my device settings, and then turning it on again!

对我来说,解决方案是从我的设备设置中关闭USB 调试,然后再次打开它!

Much quicker than restart the whole device.

比重启整个设备快得多。

回答by Sujeet Kumar

1. Open setting in ur phone.

1. 在您的手机中打开设置。

2. Go to developer options.(About Phone-> Developer Option).

2. 转到开发人员选项。(关于电话-> 开发人员选项)。

3. Disable the Developer option and again enable the Developer Option.

3. 禁用开发人员选项并再次启用开发人员选项。

4. Enable USB debugging and Install via USB.

4. 启用 USB 调试并通过 USB 安装。

回答by álvaro

Check if the option waiting for debugger is actived.

检查等待调试器的选项是否处于活动状态。

Settings -> Developer options -> Wait for debugger.

设置 -> 开发人员选项 -> 等待调试器。

I think this it is new from Jelly Bean.

我认为这是 Jelly Bean 的新产品。

回答by Barak

I'm assuming this is in the emulator and not on a device. If it is a device, ignore the rest. :p

我假设这是在模拟器中而不是在设备上。如果是设备,则忽略其余部分。:p

It sounds like you saved a snapshot of the emulator as the debugger was connecting.

听起来您在调试器连接时保存了模拟器的快照。

To fix:

修理:

1) Go to the AVD control panel, click on the emulator that's affected and hit start
2) when the window pops up, de-select "Launch from snapshot" and leave "Save to Snapshot" selected
3) Start the emulator.
4) Close the emulator
5) On the AVD control panel again start the emulator 6) Check "Launch from snapshot" again

1) 转到 AVD 控制面板,单击受影响的模拟器并点击启动
2) 弹出窗口时,取消选择“从快照启动”并选择“保存到快照”
3) 启动模拟器。
4) 关闭模拟器
5) 在 AVD 控制面板上再次启动模拟器 6) 再次选中“从快照启动”

That should fix things up.

那应该解决问题。

EDIT.

编辑

Sorry for the wasted space, I read too fast and missed you talking about trying disabling USB Debugging. I have run into the above situation I describe before so I'll leave this answer posted for those who come along who do have such an issue.

抱歉浪费了空间,我读得太快了,想念你谈论尝试禁用 USB 调试。我遇到了我之前描述的上述情况,所以我会为那些遇到这样问题的人留下这个答案。

回答by Shinoo Goyal

"Wait for debugger"in Developer options may have been set to wait your application.

开发人员选项中的“等待调试器”可能已设置为等待您的应用程序。

回答by Shinoo Goyal

Do check once that you placed breakpoints. Run app once and if you get the same message do debug as-> debug configuration-> select the app which you need to run and select always prompt to pick device.It will work for sure. It may be stupid, but i faced this problem for a long time and i tried this and this helped me. And if needed restart your device. Thanks

一旦您放置了断点,请检查一下。运行应用程序一次,如果您收到相同的消息,请执行调试为-> 调试配置-> 选择您需要运行的应用程序并选择始终提示选择设备。它肯定会工作。这可能很愚蠢,但我很长一段时间都面临这个问题,我尝试了这个,这对我有帮助。如果需要,请重新启动您的设备。谢谢

回答by Legendknight

For me, I use Android Studio 2.1.2I, I click on Menu Run > Attach debugger to Android process There is only 2 lines __device_name ____app_name I just select app_name(want to run) and click OK then miracle happens.

对我来说,我使用 Android Studio 2.1.2I,我点击 Menu Run > Attach debugger to Android process 只有 2 行 __device_name ____app_name 我只是选择 app_name(want to run) 然后点击 OK 然后奇迹发生了。

回答by lambda

I had the same problem. But restart my Device or clear the Breakpoints don't worked.

我有同样的问题。但是重新启动我的设备或清除断点不起作用。

I tried : Run --> Attach to Android Process. Select your package and press OK.

我试过:运行 --> 附加到 Android 进程。选择您的包裹,然后按 OK。

and it works :)

它有效:)