android SDK原文档如下:

Setting up a Device for Development

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.
In Eclipse, you can do this from the Application tab when viewing the Manifest (on the right side, set Debuggable to true). Otherwise, in the AndroidManifest.xml file, add android:debuggable="true" to the <application> element.


(1) Turn on "USB Debugging" on your device.
On the device, go to the home screen, press MENU, select Applications > Development, then enable USB debugging.

(2) Setup your system to detect your device.
If you're developing on Windows, you need to install a USB driver for adb. See the Windows USB Driver documentation.
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 rules file that contains a USB configuration for each type of device you want to use for development. Each device manufacturer uses a different vendor ID. The example rules files below show how to add an entry for a single vendor ID (the HTC vendor ID). In order to support more devices, you will need additional lines of the same format that provide a different value for the SYSFS{idVendor} property. For other IDs, see the table of USB Vendor IDs, below.


(3)Log in as root and create this file: /etc/udev/rules.d/51-android.rules.

For Gusty/Hardy, edit the file to read:
SUBSYSTEM=="usb", SYSFS{idVendor}=="0bb4", MODE="0666"
For Dapper, edit the file to read:
SUBSYSTEM=="usb_device", SYSFS{idVendor}=="0bb4", MODE="0666"

(4)Now execute:
chmod a+r /etc/udev/rules.d/51-android.rules


You can verify that your device is connected by executing adb devices from your SDK tools/ directory. If connected, you'll see the device name listed as a "device."

If using Eclipse, run or debug 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.





那我们的实际需要在执行的操作是:

打开终端 ,首先,以 root 权限在 /etc/udev/rules.d/ 的目录下创建 .rules 配置文件。

命令:sudo touch 51-Android.rules



接下来,我么需要编辑刚刚创建的.rules文件

命令:gedit 51-Android.rules

在其中输入:SUBSYSTEM=="usb", SYSFS{idVendor}=="0bb4", MODE="0666"



然后,赋予权限

命令:chmod a+r 51-Android.rules



重启udev

命令:sudo /etc/init.d/udev restart





到了这里基本就配置好了,我们可以拔掉手机usb 线后重新连接,在/android/sdk/tools/目录下执行 命令:adb devices

若列出设备即可开始调试

List of devices attached
HT069PL00679 device

也有可能还会遇到的问题就是

List of devices attached
?????? no permission



当然这也只是权限的问题,通过logcat查看系统日志,会发现给出了如下的提示:

will be removed in a future udev version, please use ATTR{}= to match the event device, or ATTRS{}= to match a parent device, in /etc/udev/rules.d/50-Android



问题明了,重新编辑.rules文件,将SYSFS 替换为 ATTR 即可

SUBSYSTEM=="usb", ATTR{idVendor}=="0bb4", MODE="0666"

重复接下来操作。


1. 在终端运行 lsusb

会发现结果有会有如下类似记录:

Bus 001 Device 008: ID 0bb4:0c02 High Tech Computer Corp.

这时键入

sudo vim /etc/udev/rules.d/50-Android.rules

在打开的文件中增加以下文本:

SUBSYSTEM=="usb", SYSFS{"High Tech Computer Corp."}=="0bb4", MODE="0666"

2. 运行以下命令:

sudo chmod a+rx /etc/udev/rules.d/50-Android.rules
sudo /etc/init.d/udev restart

3. 在 Android sdk 的 tools 目录下运行 (这一步很重要,必须要sudo,否则没效果)

sudo ./adb kill-server
sudo ./adb devices

然后,就可以直接用 adb 来进行操作了。


1、sudo gedit ~/.bashrc
2、将下面的两句加到上面打开的文件里
export ANDROID_HOME=/home/jason/Develop_SDK/android-sdk-linux_86
export PATH=$PATH:$ANDROID_HOME/tools
最新的SDK要改为:$PATH:$ANDROID_HOMOE/platform-tools
注意:“/home/jason/Develop_SDK/android-sdk-linux_86”是sdk的路径.
3、重启电脑,OK啦!

更多相关文章

  1. NPM 和webpack 的基础使用
  2. 【阿里云镜像】使用阿里巴巴DNS镜像源——DNS配置教程
  3. 2011.09.07(4)——— android 跨进程通信之content provider
  4. android 往sd卡中写入文件
  5. Android(安卓)建立文件夹、生成文件并写入文本文件内容
  6. Android打印工具类
  7. android light
  8. Android(安卓)读写文件的N种写法
  9. 关于资源文件:颜色

随机推荐

  1. android中进行https连接的方式的详解
  2. Android(安卓)自定义 Dialog 大小 位置
  3. android项目案例6- 基于Android(安卓)stu
  4. android - AsyncTask 的使用
  5. android 地图
  6. Android进阶(十八)AndroidAPP开发问题汇
  7. switchpreference属性
  8. Android中关联源码
  9. SOAP in Android
  10. CouchDB降临Android