[置顶] 设置设备进行开发
由于手机恢复出产设置,Ubuntu Linux无法识别手机了,这里找来Google官方配置资料,记录下,以防再次出现类似问题。
使用Android设备,只需要完成以下几步,你可以像在模拟器上一样开发和调试你的Android应用。
1.在AndroidManifest文件中声明你的应用是可调试的。
如果你使用Eclipse进行开发,这一步可以跳过,在AndroidManifest.xml文件中在application标签元素中添加android:debuggable="true"。注:如果你手动地使能调试,要确保在发布软件的时候去掉使能。
2.在设备上使能USB调试功能。
(1)在运行Android3.2或者更低版本的大多数设备上,可以在设置——>应用——>开发进行设置。
(2)在Android4.0或者更新的设备上,可以在设置——>开发者选项进行设置。
注:在Android4.2或者更新的设备上,开发者选项默认是隐藏的。可以通过设置——>关于手机——>点击版本号,然后返回先前的屏幕查找开发者选项,进行设置。
3.设置系统检测设备
(1)如果你在Windows下开发,你需要安装adb的USB驱动。安装指南和OEM驱动链接清查看:OEM USB Drivers文件。
(2)如果你在Mac OS下开发,这一步可以跳过。
(3)如果你在Ubuntu下开发,你需要添加udev规则文件,该文件包含你想要进行开发的每种设备的USB配置。在规则文件中,每个设备生产商由唯一的供应商ID标识,通过ATTR{idVendor}属性指定。供应商ID请查看下面的列表:USB Vendor IDs。
设置Ubuntu检测设备的步骤如下:
a.以root用户登录系统,创建文件/etc/udev/rules.d/51-android.rules。使用如下格式添加每个供应商规则:SUBSYSTEM=="usb", ATTR{idVendor}=="0bb4", MODE="0666", GROUP="plugdev"
例子中使用的是HTC的供应商ID,MODE指定读写权限,GROUP定义该设备节点被哪个用户组拥有。注:规则语法可能根据环境而有所变化,根据自己的需要查看udev文件。可以查看writing udev rules熟悉语法。
b.给规则文件添加执行权限。 当你连接一个运行Android4.2.2或者更高版本的设备时,系统会显示询问是否接受一个RSA key,从而允许电脑进行调试的对话框。这种安全机制保护了用户设备的安全,因为它确保了USB调试或者其他的adb命令只有在用户对设备解锁并且确认之后才能执行。为了调试运行Android4.2.2或者更高版本的设备,需要adb版本为1.0.31(在r16.0.1或者更高版本的SDK工具中可用)。
使用USB时,可以通过执行adb devices命令验证设备已经连接,这时你可以看到设备名被列出。
如果使用Eclipse,像往常一样运行或者调试,就可以选择可用的模拟器或者已经连接的设备,选择你想要进行安装和运行的设备即可。
如果使用Android Debug Bridge (adb),可以使用带有d标志的adb命令选择连接的设备。
以下是供应商的ID。
USB Vendor IDs
This table provides a reference to the vendor IDs needed in order to add USB device support on Linux. The USB Vendor ID is the value given to the ATTR{idVendor}
property in the rules file, as described above.
Company | USB Vendor ID |
---|---|
Acer | 0502 |
ASUS | 0b05 |
Dell | 413c |
Foxconn | 0489 |
Fujitsu | 04c5 |
Fujitsu Toshiba | 04c5 |
Garmin-Asus | 091e |
18d1 |
|
Haier | 201E |
Hisense | 109b |
HTC | 0bb4 |
Huawei | 12d1 |
K-Touch | 24e3 |
KT Tech | 2116 |
Kyocera | 0482 |
Lenovo | 17ef |
LG | 1004 |
Motorola | 22b8 |
MTK | 0e8d |
NEC | 0409 |
Nook | 2080 |
Nvidia | 0955 |
OTGV | 2257 |
Pantech | 10a9 |
Pegatron | 1d4d |
Philips | 0471 |
PMC-Sierra | 04da |
Qualcomm | 05c6 |
SK Telesys | 1f53 |
Samsung | 04e8 |
Sharp | 04dd |
Sony | 054c |
Sony Ericsson | 0fce |
Teleepoch | 2340 |
Toshiba | 0930 |
ZTE | 19d2 |
原文:
With an Android-powered device, you can develop and debug your Android applications just as you would on the emulator. Before you can start, there are just a few things to do:
- Declare your application as "debuggable" in your Android Manifest.
When using Eclipse, you can skip this step, because running your app directly from the Eclipse IDE automatically enables debugging.
In the
AndroidManifest.xml
file, addandroid:debuggable="true"
to the<application>
element.Note: If you manually enable debugging in the manifest file, be sure to disable it before you build for release (your published application should usually not be debuggable).
- Enable USB debugging on your device.
- On most devices running Android 3.2 or older, you can find the option under Settings > Applications > Development.
- On Android 4.0 and newer, it's in Settings > Developer options.
Note: On Android 4.2 and newer, Developer options is hidden by default. To make it available, go to Settings > About phone and tap Build number seven times. Return to the previous screen to find Developer options.
- Set up your system to detect your device.
- If you're developing on Windows, you need to install a USB driver for adb. For an installation guide and links to OEM drivers, see the OEM USB Drivers document.
- If you're developing on Mac OS X, it just works. Skip this step.
- If you're developing on Ubuntu Linux, you need to add a
udev
rules file that contains a USB configuration for each type of device you want to use for development. In the rules file, each device manufacturer is identified by a unique vendor ID, as specified by theATTR{idVendor}
property. For a list of vendor IDs, see USB Vendor IDs, below. To set up device detection on Ubuntu Linux:- Log in as root and create this file:
/etc/udev/rules.d/51-android.rules
.Use this format to add each vendor to the file:
SUBSYSTEM=="usb", ATTR{idVendor}=="0bb4", MODE="0666", GROUP="plugdev"
In this example, the vendor ID is for HTC. TheMODE
assignment specifies read/write permissions, andGROUP
defines which Unix group owns the device node.Note: The rule syntax may vary slightly depending on your environment. Consult the
udev
documentation for your system as needed. For an overview of rule syntax, see this guide to writing udev rules. - Now execute:
chmod a+r /etc/udev/rules.d/51-android.rules
- Log in as root and create this file:
Note: When you connect a device running Android 4.2.2 or higher to your computer, the system shows a dialog asking whether to accept an RSA key that allows debugging through this computer. This security mechanism protects user devices because it ensures that USB debugging and other adb commands cannot be executed unless you're able to unlock the device and acknowledge the dialog. This requires that you have adb version 1.0.31 (available with SDK Platform-tools r16.0.1 and higher) in order to debug on a device running Android 4.2.2 or higher.
When plugged in over USB, you can verify that your device is connected by executing adb devices
from your SDKplatform-tools/
directory. If connected, you'll see the device name listed as a "device."
If using Eclipse, run or debug your application as usual. You will be presented with a Device Chooser dialog that lists the available emulator(s) and connected device(s). Select the device upon which you want to install and run the application.
If using the Android Debug Bridge (adb), you can issue commands with the -d
flag to target your connected device.
USB Vendor IDs
This table provides a reference to the vendor IDs needed in order to add USB device support on Linux. The USB Vendor ID is the value given to the ATTR{idVendor}
property in the rules file, as described above.
Company | USB Vendor ID |
---|---|
Acer | 0502 |
ASUS | 0b05 |
Dell | 413c |
Foxconn | 0489 |
Fujitsu | 04c5 |
Fujitsu Toshiba | 04c5 |
Garmin-Asus | 091e |
18d1 |
|
Haier | 201E |
Hisense | 109b |
HTC | 0bb4 |
Huawei | 12d1 |
K-Touch | 24e3 |
KT Tech | 2116 |
Kyocera | 0482 |
Lenovo | 17ef |
LG | 1004 |
Motorola | 22b8 |
MTK | 0e8d |
NEC | 0409 |
Nook | 2080 |
Nvidia | 0955 |
OTGV | 2257 |
Pantech | 10a9 |
Pegatron | 1d4d |
Philips | 0471 |
PMC-Sierra | 04da |
Qualcomm | 05c6 |
SK Telesys | 1f53 |
Samsung | 04e8 |
Sharp | 04dd |
Sony | 054c |
Sony Ericsson | 0fce |
Teleepoch | 2340 |
Toshiba | 0930 |
ZTE | 19d2 |
原文地址:点击打开链接
相关文章
- 从Android设备中提取内核和逆向分析
- VMWare ESXi 开启显卡直通 (PCI 设备直通) 出现 DevicePowerOn 错误
- 嵌入式(字符设备驱动基础下_并发控制)
- airtest+poco多脚本、多设备批处理运行测试用例自动生成测试报告
- 物联网设备安全2.1 酒店门锁和磁卡
- 可穿戴医疗保健设备拥有巨大发展前景
- 《精通Linux设备驱动程序开发》——1.6 查看源代码
- 《精通Linux设备驱动程序开发》——1.7 编译内核
- 《嵌入式设备驱动开发精解》——第2章 如何开始嵌入式开发 2.1 什么是嵌入式系统
- 《HTML5触摸界面设计与开发》——第 1 章 移动设备概述1.1 触摸设备和桌面设备之间的差异
- 《iOS 6高级开发手册(第4版)》——1.4节秘诀:取回额外的设备信息
- 木马感染千万安卓设备 其开发团队或与北京公司相关联
- School StartsFirstProject~UnityVR(HTCVive设备开发)
- 【正点原子FPGA连载】第二十三章字符设备驱动开发 摘自【正点原子】DFZU2EG_4EV MPSoC之嵌入式Linux开发指南
- 【正点原子MP157连载】第二十二章 新字符设备驱动实验-摘自【正点原子】STM32MP1嵌入式Linux驱动开发指南V1.7
- 高通推虚拟现实开发工具包 为骁龙芯片设备打造
- 1970“变种”bug连WiFi热点iOS设备会变砖?
- 为抵抗黑客攻击 国外公司开发了一套智能家居设备
- 技术研究 | 我所了解的物联网设备渗透手段(硬件篇)