命令行工具ADB(Andvoid Debug Bridge)是Android提供的一个通用的调试工具,借助这个工具,我们可以管理设备或手机模拟器的状态。
adb help
AndroidDebugBridgeversion
1.0.20
-d-
directs command to the only connected USB
device
returns
an error if more than one USB device is
present.
-e-
directs command to the only running
emulator.
returns
an error if more than one emulator is
running.
-s -
directs command to the USB device or emulator
with
the
given serial number
-p -
simple product name like 'sooner', or
a
relative/absolute path to a product
out
directory like
'out/target/product/sooner'.
If
-p is not specified, the ANDROID_PRODUCT_
environment
variable is used, which must
be
an absolute path.
devices-
list all connected devices
device commands:
adb push -
copy file/dir to device
adb pull -
copy file/dir from device
adb sync [
]-
copy host->device only if changed
(see
'adb help all')
adbshell-
run remote shell interactively
adb shell
-
run remote shell command
adb emu -
run emulator console command
adb logcat [ ] - View
device log
adb forward - forward
socket connections
tcp:
localabstract:
localreserved:
localfilesystem:
dev:
jdwp:
(remote only)
adb jdwp-
list PIDs of processes hosting a JDWP
transport
adb install [-l] [-r]
- push this package file to the device and install
it
('-l'
means forward-lock the app)
('-r'
means reinstall the app, keeping its data)
adb uninstall [-k] -
remove this app package from the device
('-k'
means keep the data and cache directories)
adb
bugreport-
return all information from the device
that
should be included in a bug report.
adb help-
show this help message
adb
version-
show version num
DATAOPTS:
(no
option)-
don't touch the data partition
-w-
wipe the data partition
-d-
flash the data partition
adb
wait-for-device-
block until device is online
adb
start-server-
ensure that there is a server running
adb
kill-server-
kill the server if it is running
adb
get-state-
prints: offline | bootloader | device
adb
get-product-
prints:
adb
get-serialno-
prints:
adb
status-window-
continuously print device status for a specified
device
adb
remount-
remounts the /system partition on the device
read-write
networking:
adb ppp
[parameters]-
Run PPP over USB.
Note: you should not
automatically start a PDP connection.
refers to the tty
for PPP stream. Eg.
dev:/dev/omap_csmi_tty1
[parameters] - Eg.
defaultroute debug dump local notty
usepeerdns
adb sync notes: adb sync [
]
can be interpreted
in several ways:
- If is not
specified, both /system and /data partitions will be
updated.
- If it is "system"
or "data", only the corresponding
partitionis
updated.
ADB还可以进行以下的操作:
1、快速更新设备或手机模拟器中的代码,如应用或Android系统升级;
2、在设备上运行shell命令;
3、管理设备或手机模拟器上的预定端口;
4、在设备或手机模拟器上复制或粘贴文件;
5、安装.apk文件到仿真器上。
以下为一些常用的操作:
1、安装应用到模拟器:
adb
install
比较郁闷的是,Android并没有提供一个卸载应用的命令,只能自己手动删除:
adb
shell
cd
/data/app
rm
app.apk
2、进入设备或模拟器的shell:
adb
shell
通过上面的命令,就可以进入设备或模拟器的shell环境中,在这个LinuxShell中,你可以执行各种Linux的命令,另外如果只想执行一条shell命令,可以采用以下的方式:
adb shell
[command]
如:adb shell
dmesg会打印出内核的调试信息。
3、发布端口:
你可以设置任意的端口号,做为主机向模拟器或设备的请求端口。如:
adb forward
tcp:5555 tcp:8000
4、复制文件:
你可向一个设备或从一个设备中复制文件,
复制一个文件或目录到设备或模拟器上:
adb
push
如:adb
pushtest.txt
/tmp/test.txt
从设备或模拟器上复制一个文件或目录:
adb
pull
如:adb pull /addroid/lib/libwebcore.so
.
5、搜索模拟器/设备的实例:
取得当前运行的模拟器/设备的实例的列表及每个实例的状态:
adb
devices
6、查看bug报告:
adb
bugreport
7、记录无线通讯日志:
一般来说,无线通讯的日志非常多,在运行时没必要去记录,但我们还是可以通过命令,设置记录:
adb
shell
logcat -b
radio
8、获取设备的ID和序列号:
adb
get-product
adb
get-serialno
9、访问数据库SQLite3
adb
shell
sqlite3
安卓网的一个帖子,写得不错,记下来
ADB全称AndroidDebugBridge,
是android sdk里的一个工具,
用这个工具可以直接操作管理android模拟器或者真实的andriod设备(如G1手机).
它的主要功能有:
-
运行设备的shell(命令行)
-
管理模拟器或设备的端口映射
-
计算机和设备之间上传/下载文件
- 将本地apk软件安装至模拟器或android设备
ADB是一个 客户端-服务器端程序,
其中客户端是你用来操作的电脑,
服务器端是android设备.
先说安装方法, 电脑上需要安装客户端. 客户端包含在sdk里. 设备上不需要安装,
只需要在手机上打开选项settings-applications-development-USBdebugging.
对于Mac和Linux用户, 下载好的sdk解压后, 可以放~或者任意目录.
然后修改~/.bash_profile文件,设置运行环境指向sdk的tools目录.
具体是打开~/.bash_profile文件(如果没有此文件也可以自行添加), 在里面加入一行:
export PATH=${PATH}:<你的sdk目录>/tools
然后就可以使用adb命令了.
嫌安装麻烦的同学其实也可以省去上面安装步骤, 直接输入完整路径来使用命令
对于windows xp用户, 需要先安装usb驱动shell命令详解ZZ" />android_usb_windows.zip(1.33
MB), 然后如果你只打算使用adb而不想下载整个sdk的话,
可以下载这个单独的adb工具包shell命令详解ZZ" />adb_win.zip(571.56
KB)下载后解压, 把里面 adb.exe 和 AdbWinApi.dll
两个文件放到系统盘的
windows/system32 文件夹里就可以了
ADB常用的几个命令
1. 查看设备
这个命令是查看当前连接的设备,
连接到计算机的android设备或者模拟器将会列出显示
2. 安装软件
这个命令将指定的apk文件安装到设备上
3. 卸载软件
- adb uninstall
<软件名>
- adb uninstall -k
<软件名>
如果加 -k
参数,为卸载软件但是保留配置和缓存文件.
4. 登录设备shell
这个命令将登录设备的shell.
后面加将是直接运行设备命令, 相当于执行远程命令
5. 从电脑上发送文件到设备
用push命令可以把本机电脑上的文件或者文件夹复制到设备(手机)
6. 从设备上下载文件到电脑
用pull命令可以把设备(手机)上的文件或者文件夹复制到本机电脑
7. 显示帮助信息
这个命令将显示帮助信息
删除Android系统Rom自带的软件
Android系统没有卸载Rom自带软件的功能.可能有些同学很想删除废了武功的Youtube,想删除墙那边的Twitter.
加上Android的快捷方式没法修改没法自己排序没法分页.
安装的程序太多就会发现原来找到自己想要的东西很难.
综上所述,我觉得告知各位菜鸟同学如何删除自带的程序是很有必要的一件事情.
1.确定手机root了,取得了root权限才能删除系统文件呀.
2.下载Android_db.rar,解压到%windir/%System32下.
3.手机连接数据线,在电脑上打开cmd,然后输入命令
adb remount
adb shell
su
执行完成之后,你会看到:
* daemon not
running. starting it now *
* daemon started
successfully *
4.接着就是Linux命令行模式了,输入
cd system/app
你会发现没啥变化,然后输入ls回车.
这时候列表显示了system/app里面的所有文件,也就是Rom集成的一些软件了.
5.开始删除吧.比如删除Youtube,他的文件名是Youtube.odex和Youtube.apk
我们要删除这2个文件,敲入以下命令:
rm Youtube.*
重启,Youtube已经删除掉了,注意各位同学千万不要删除你不知道是啥的东西.
原文链接:
http://www.hiapk.com/bbs/thread-623-1-1.html
指定允许AVD的内存大小:
emulator -avd
avdName -partition-size 256
启动一个叫avdName的模拟器,允许内存最大为256M
adb -d
当Android手机用USB连接计算机时可通过adb-d对该装置下命令
adb -e对正在运行的仿真器下指令
adb -s指定仿真器序号
adb dervices显示当前启动的仿真器装置序号
adb help显示adb指令用法
adb verson显示adb版本
adb install安装APK应用程序组件
adb push上传文件或目录(adb push 文件所在PC的位置即文件名 目的位置)
adb pull下载文件或目录(adb pull 文件所在手机的位置即文件名 目的位置)
adb shell进入Android系统命令行模式
adb logcat监控仿真器运行记录
adb bugreport生成adb出错报告
adb start-server启动adb服务器
adb kill-server关闭adb服务器
adb get-state取得adb服务器运行状态
adb get-serialno获得仿真器运行序号
adb forward tcp:port更改仿真器的网络TCP通信端口
|