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

我的问题 :

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

我想要的 :

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

我所尝试过的:

  • 我已经尝试设置 android:debuggable="false",但如果我这样做,调试器永远不会连接,消息永远不会消失。
  • 我也试过在安装后禁用 USB Debugging,但仍然没有结果。
  • 即使我关闭应用程序并通过外部源唤醒它(它使用 Google 的 C2D 消息框架) ,它仍然会尝试在唤醒时以调试模式运行。

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

如果有必要,我可以发布来自 AndroidManifest 或其他代码部分的代码片段,但正如我前面提到的,几天前我并没有得到这种奇怪的行为。

68033 次浏览

I'm assuming this is in the emulator and not on a device. If it is a device, ignore the rest. :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

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.

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

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

Check if the option waiting for debugger is actived.

Settings -> Developer options -> Wait for debugger.

I think this it is new from Jelly Bean.

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

Your manifest file may contain following permission

Just remove this permission

<uses-permission android:name="android.permission.SET_DEBUG_APP"/>

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

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

Much quicker than restart the whole device.

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.

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.

and it works :)

You can also set your Android App as Debugging-App Settings --> Developer Options --> set Debuging-App

there you can choice your app

1. Open setting in ur phone.

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

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

4. Enable USB debugging and Install via USB.

There was so many adb processes running ,I kill them all and its start debugging

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

Run this command and the issue will be resolved

adb shell am clear-debug-app

You might have added your app in Select app to be debugged on your phone. In Settings -> Developer Options -> Select app to be debugged

To resolve this, go to Select app to be debugged and click on No apps