将 Android 应用程序调试到手机
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2812442/
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
Debugging an Android app to the phone
提问by tipu
I've gone through the page Using Hardware Devices. My manifest has
我已经浏览了使用硬件设备页面。我的清单有
<application android:icon="@drawable/icon"
android:label="@string/app_name"
android:debuggable="true">
My phone has Menu-> Settings-> Applications-> Development-> USB Debuggingchecked.
我的手机已选中菜单->设置->应用程序->开发-> USB 调试。
I have gone to the control panel on my Windows XP 64 bit installation and installed the USB drivers given to me by the SDK installer in android-sdk_r05-windows\android-sdk-windows\usb_driver
. So my computer does recognize the Android device.
我已经转到 Windows XP 64 位安装的控制面板,并安装了 SDK 安装程序提供给我的 USB 驱动程序android-sdk_r05-windows\android-sdk-windows\usb_driver
。所以我的电脑确实可以识别 Android 设备。
However.. when I run an app on Eclipse, it still insists on opening it up in an emulator rather than my phone. How can I fix that?
但是.. 当我在 Eclipse 上运行一个应用程序时,它仍然坚持在模拟器而不是我的手机中打开它。我该如何解决?
采纳答案by Hartigan
I just picked up Android development again, and this is what worked for me using HTC Hero(2.1 update 1) on Eclipse (v. 3.6 (Helios), Service Release 1):
我刚刚又开始了 Android 开发,这就是在 Eclipse(v. 3.6 (Helios),Service Release 1)上使用HTC Hero(2.1 更新 1)对我有用的方法:
- Start up Eclipse
- Connect the phone
- Ensure USB debugging is enabled
- Set phone connection type to HTC sync,
as opposed to charge only, etc.
(You don't have to sync, but it need to be in this mode. A message will then be displayed in the task bar saying USB debugging is connected or something similar. Then follow AlexVolovoy's instructions (Right click on the Eclipse project -> Run As-> Run Configuration-> Target- Choose manual) and you should be good to go. Just remember to pick your phone from the list of targets.
- 启动 Eclipse
- 连接手机
- 确保已启用 USB 调试
- 将手机连接类型设置为HTC 同步,而不是仅充电等
(您不必同步,但必须处于此模式。然后任务栏中会显示一条消息,提示 USB 调试已连接或类似的东西。然后按照 AlexVolovoy 的说明(右键单击 Eclipse 项目 ->运行方式->运行配置->目标- 选择手册),你应该很高兴。记住从目标列表中选择你的手机。
回答by Alex Volovoy
See if this helps:
看看这是否有帮助:
- Right click on the Eclipse project -> Run As-> Run Configuration-> Target- Choose manual
- 右键单击Eclipse项目->运行方式->运行配置->目标-选择手动
The same goes for Debug
.
也是如此Debug
。
回答by Dilruk
2 steps to follow
2个步骤
Enable USB debugging mode in your android phone. settings > Applications > development > enable the "USB debugging" check box
Enable manual deployment target on eclipse. Right Click on project > Run As > run configurations > select the "Target" tab > select the "Deployment Target Selection Mode" as ""manual""
在您的 Android 手机中启用 USB 调试模式。设置 > 应用程序 > 开发 > 启用“USB 调试”复选框
在 Eclipse 上启用手动部署目标。右键单击项目>运行方式>运行配置>选择“目标”选项卡>选择“部署目标选择模式”为“手动”
Now run your application normally and you will be asked to choose the device you wanna run.
现在正常运行您的应用程序,系统会要求您选择要运行的设备。
Then you can simply select the device you wish to run (Using serial number of the phone, if there are many devices running at the same time).
然后您可以简单地选择您想要运行的设备(使用手机的序列号,如果有许多设备同时运行)。
回答by Mark
On the phone, go to Settings-> Applications-> Developmentand make sure USB Debugging is enabled. (This location is from a Nexus One, it may be different on other Android versions)
在手机上,转到设置->应用程序->开发并确保启用了 USB 调试。(此位置来自Nexus One,其他 Android 版本可能有所不同)
I'm not sure all phones support this, the Android Dev Phone 1, Android Dev Phone 2, and the Nexus One do.
我不确定所有手机都支持这一点,Android Dev Phone 1、Android Dev Phone 2和 Nexus One 都支持。
Once you do this, the phone should appear in the dialog you posted a link to in your comment on Alex's answer.
完成此操作后,电话应出现在您在对 Alex 的回答发表评论时发布链接的对话框中。