Java Android Studio:在设备上调试应用程序
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19517480/
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
Android studio: debug application on device
提问by user1248568
I have difficulties with with debugging at Android Studio. After trying to launch application in debug mode device show alert with "Waiting For Debugger" title that never disappear. Also I have android:debuggable="true"
in my manifest file and seems like device connected correctly, because I can simply run my application without any problem. What I'm doing wrong?
我在 Android Studio 调试时遇到困难。尝试在调试模式下启动应用程序后,设备显示带有“等待调试器”标题的警报,该标题永远不会消失。此外android:debuggable="true"
,我的清单文件中也有设备连接正确,因为我可以简单地运行我的应用程序而没有任何问题。我做错了什么?
采纳答案by fasteque
Remove android:debuggable="true"
, because when you run/debug an application in Android Studio is signed with a debug certificate so that setting is not mandatory.
删除android:debuggable="true"
,因为当您运行/调试 Android Studio 中的应用程序时,会使用调试证书进行签名,因此该设置不是强制性的。
Then check from console if the device is correctly attached with an adb devices
. You should see it listed.
然后从控制台检查设备是否正确连接了adb devices
. 你应该会看到它被列出来。
Then try in this way:
然后试试这样:
1 - close Android Studio and any other IDE you have opened (maybe you have Eclipse also running?) and emulator instances;
1 - 关闭 Android Studio 和您打开的任何其他 IDE(也许您还运行 Eclipse?)和模拟器实例;
2 - remove USB cable from PC;
2 - 从 PC 上拔下 USB 线;
3 - run adb kill-server
from console;
3 -adb kill-server
从控制台运行;
4 - open Android Studio;
4 - 打开安卓工作室;
5 - click on run/debug;
5 - 点击运行/调试;
6 - when the window to select the device appears, attach your device to USB and USB to your computer;
6 - 当出现窗口选择设备时,将设备连接到USB和USB到您的计算机;
回答by Max McKinney
Remove those lines related to debugging. When you launch an application from Android Studio it is signed with a debug key. Any debugging information you need can be viewed in logcat from Android Studio. Also make sure you are running the latest version (help -> check for updates) I think that's where its at.
删除与调试相关的那些行。当您从 Android Studio 启动应用程序时,它会使用调试密钥进行签名。您需要的任何调试信息都可以在 Android Studio 的 logcat 中查看。还要确保您运行的是最新版本(帮助-> 检查更新),我认为这就是它所在的位置。
回答by Nick Wood
also try restarting the device - that worked for me when I had the same issue
也尝试重新启动设备 - 当我遇到同样的问题时,这对我有用
回答by Andrey
I have similar issue (running Android Studio on Ubuntu)
我有类似的问题(在 Ubuntu 上运行 Android Studio)
What I do:
我所做的:
- Close Android Studio (and Emulator(s) if running)
Go to adb folder (/wherever_location_is/sdk/platform-tools) and run command:
./adb kill-server
Open Android Studio.
- 关闭 Android Studio(如果正在运行,则关闭模拟器)
转到 adb 文件夹(/wherever_location_is/sdk/platform-tools)并运行命令:
./adb 杀死服务器
打开安卓工作室。
Now Logcat messages appear again.
现在再次出现 Logcat 消息。
回答by pepan
I'm struggling with similar issue every day and as restarting the studio or the device is pretty time consuming (and sometimes even does not work), I was trying many things and by coincidence I found an awkward (but working) solution.
我每天都在为类似的问题苦苦挣扎,因为重新启动工作室或设备非常耗时(有时甚至不起作用),我尝试了很多东西,巧合的是我找到了一个尴尬(但有效)的解决方案。
When you are in the situation when you hit debug button in Android Studio, the studio says it's connected and the device says: Waiting for Debugger, but the device waits forever, do this:
当你在 Android Studio 中点击调试按钮时,工作室说它已连接并且设备说:等待调试器,但设备永远等待,执行以下操作:
- In Android Studio, hit the 'Edit Configurations' pop-up button
- Once the Run/Debug Configurations dialog opens, the debug process starts!
- 在 Android Studio 中,点击“编辑配置”弹出按钮
- 一旦运行/调试配置对话框打开,调试过程就开始了!
Works like a miracle!
像奇迹一样工作!
回答by Muhamed Riyas M
I had the same problem when i enabled the Proguard for debug!, Please disable it and try !!!
当我启用 Proguard 进行调试时,我遇到了同样的问题!请禁用它并尝试!
回答by Merhawi Fissehaye
I think this might help. After launching application, click on Run and find Attach Debugger to Android Process
[
我认为这可能会有所帮助。启动应用程序后,点击 Run 并找到 Attach Debugger to Android Process [
回答by Manju
Check in gradle. if you apply proguard for debug then dubugging process not applicable to app.Make sure minifyEnabled false in debug.
检查gradle。如果您应用 proguard 进行调试,则调试过程不适用于应用程序。请确保调试中的 minifyEnabled 为 false。