您的位置:首页 > 移动开发 > Android开发

Android 开发Ubuntu下 adt 手机连接开发

2016-03-31 21:03 471 查看
环境:Ubuntu 13.04 64bit

第一步 安装配置ADB

首先需安装jdk并配置环境变量

1、下载sdk for linux

http://developer.android.com/sdk/index.html

2、解压缩,并更新

cd ~/android-sdk-linux/tools

./andirod

3、配置环境变量

sudo gedit ~/.bashrc

 

#set path for android sdk tools

export PATH=$PATH:~/android-sdk-linux/tools/

export PATH=$PATH:~/android-sdk-linux/platform-tools/

 

4、保存后,同步更新

source ~/.bashrc

5、直接运行adb的话会显示

adb devices

* daemon not running. starting it now on port 5037 *

* daemon started successfully *

List of devices attached

???????????? no permissions

没有权限

5、关闭adb服务,切换到root,重启adb服务,离开root

adb kill-server

sudo su

/home/m/android-sdk-linux/platform-tools/adb start-server

exit

现在即可使用adb了

第二步 配置手机
          Android Developer Tools

         Build: v22.2.1-833290

          This product includes Eclipse Platform, JDT, CDT, EMF, GEF and WTP,

          all of which are Copyright (c) Eclipse contributors and others.

          Android Developer Tools are Copyright (c) The Android Open Source Project.( o; n7 y" Q. k$ I

问题描述:在terminal下输入adb devices显示不出设备,在eclipse中选择运行程序显示找不到设备,后来查些资料发现ubuntu下面连接设备需要一些特殊配置。
adb devices后只显示“List of devices attached”,不罗列设备,确定usb已经连上。如下图:



 
启动Eclipse,在Devices栏会现一个有很多???号的不明设备。
解决方法:

1)在PC下找到文件 ~/.android/adb_usb.ini,若没有新建:vi ~/.android/adb_usb.ini。

2)添加idVender:echo "idVender" > ~/.android/adb_usb.ini,其中的idVebder是lsusb显示内容的ID后的前一个数值。注意:前面要加0x 。           如:echo "0x1d6b"
> ~/.android/adb_usb.ini 。

其中idVebder即经销商ID(Vendor ID)。

Google官方的VendorId 列表如下:

厂商名   厂商ID

Acer
0502

ASUS
0b05

Dell
413c

Foxconn
0489

等等……

如果不是的话需要得到设备的VendorId添加进去

在终端执行: lsusb 将会列出系统所有在用的usb端口信息,如果有很多的话需要自己根据后面的描述分辨。

bus 001 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

bus 002 Device 002: ID 80ee:0021 VirtualBox USB Tablet

bux 003 Device 003: ID 18d1:9025 Google Inc

因为我是用的虚拟机,所以有80ee:0021
VirtualBox USB Tablet

我的小米1手机的ID是ID
18d1:9025 Google Inc

3)确定echo添加的idVender已经生效:cat /root/.android/adb_usb.ini

4)连接usb后重启adb-server:

         adb kill-server

         adb start-server

        5)(很重要)拔掉usb重新连上)

        6)验证:adb devices
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  android 手机 adt ubuntu