adb介绍
SDK的Tools文件夹下包含着Android模拟器操作的重要命令adb,adb的全称为(Android Debug Bridge就是调试桥的作用。通过adb我们可以在Eclipse中方面通过DDMS来调试Android程序。借助这个工具,我们可以管理设备或手机模拟器的状态。还可以进行以下的操作:
1、快速更新设备或手机模拟器中的代码,如应用或Android 系统升级;
2、在设备上运行shell命令;
3、管理设备或手机模拟器上的预定端口;
4、在设备或手机模拟器上复制或粘贴文件;
adb在集成开发环境中的工作
adb的工作方式比较特殊采用监听Socket TCP 5554等端口的方式让IDE和Qemu通讯,默认情况下adb会daemon相关的网络端口,所以当我们运行Eclipse时adb进程就会自动运行。
1.通过adb可以轻松的执行Linux Shell命令,如adb shell dir 就是列举目录,在Linux中根目录为/而不是Windows上的C盘、D盘。
2.安装apk程序到模拟器则执行adb install android123.apk,这样名为android123的安装包就会安装到Android模拟器中,前提是android123.apk文件需要放到SDK/Tools目录下。
3.向emulator传送文件, 使用adb push android123.txt /tmp/android123.txt命令可以把SDK/Tools下的android123.txt文件传输到模拟器的/tmp/文件夹中,需要注意的是/tmp/文件夹中内容会在Android模拟器重新启动时清空。
4.从Android仿真器中回传文件到电脑
通过adb pull /tmp/android123.txt android123.txt命令就会把仿真器的tmp文件夹下android123.txt文件回传到电脑SDK/Tools目录下。
adb 常用命令大全
1. 显示系统中全部Android平台:
android list targets
2. 显示系统中全部AVD(模拟器):
android list avd
3. 创建AVD(模拟器):
android create avd --name 名称 --target 平台编号
4. 启动模拟器:
emulator -avd 名称 -sdcard ~/名称.img (-skin 1280x800)
5. 删除AVD(模拟器):
android delete avd --name 名称
6. 创建SDCard:
mksdcard 1024M ~/名称.img
7. AVD(模拟器)所在位置:
Linux(~/.android/avd) Windows(C:\Documents and Settings\Administrator\.android\avd)
8. 启动DDMS:
ddms
9. 显示当前运行的全部模拟器:
adb devices
10. 对某一模拟器执行命令:
abd -s 模拟器编号 命令
11. 安装应用程序:
adb install -r 应用程序.apk
12. 获取模拟器中的文件:
adb pull <remote> <local>
13. 向模拟器中写文件:
adb push <local> <remote>
14. 进入模拟器的shell模式:
adb shell
15. 启动SDK,文档,实例下载管理器:
android
16. 缷载apk包:
adb shell
cd data/app
rm apk包
exit
adb uninstall apk包的主包名
adb install -r apk包
17. 查看adb命令帮助信息:
adb help
18. 在命令行中查看LOG信息:
adb logcat -s 标签名
19. adb shell后面跟的命令主要来自:
源码\system\core\toolbox目录和源码\frameworks\base\cmds目录。
20. 删除系统应用:
adb remount (重新挂载系统分区,使系统分区重新可写)。
adb shell
cd system/app
rm *.apk
21. 获取管理员权限:
adb root
22. 启动Activity:
adb shell am start -n 包名/包名+类名(-n 类名,-a action,-d date,-m MIME-TYPE,-c category,-e 扩展数据,等)。
23、发布端口:
你可以设置任意的端口号,做为主机向模拟器或设备的请求端口。如:
adb forward tcp:5555 tcp:8000
24、复制文件:
你可向一个设备或从一个设备中复制文件,
复制一个文件或目录到设备或模拟器上:
adb push <source> <destination></destination></source>
如:adb push test.txt /tmp/test.txt
从设备或模拟器上复制一个文件或目录:
adb pull <source> <destination></destination></source>
如:adb pull /addroid/lib/libwebcore.so .
25、搜索模拟器/设备的实例:
取得当前运行的模拟器/设备的实例的列表及每个实例的状态:
adb devices
26、查看bug报告:
adb bugreport
27、记录无线通讯日志:
一般来说,无线通讯的日志非常多,在运行时没必要去记录,但我们还是可以通过命令,设置记录:
adb shell
logcat -b radio
28、获取设备的ID和序列号:
adb get-product
adb get-serialno
29、访问数据库SQLite3
adb shell
sqlite3
#cd system/sd/data //进入系统内指定文件夹
#ls //列表显示当前文件夹内容
#rm -r xxx //删除名字为xxx的文件夹及其里面的所有文件
#rm xxx //删除文件xxx
#rmdir xxx //删除xxx的文件夹
Android Debug Bridge version 1.0.31 -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 <specific device> - directs command to the device or emulator with the given serial number or qualifier. Overrides ANDROID_SERIAL environment variable. -p <product name or path> - 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_OUT environment variable is used, which must be an absolute path. devices [-l] - list all connected devices ('-l' will also list device qualifiers) connect <host>[:<port>] - connect to a device via TCP/IP Port 5555 is used by default if no port number is specified. disconnect [<host>[:<port>]] - disconnect from a TCP/IP device. Port 5555 is used by default if no port number is specified. Using this command with no additional arguments will disconnect from all connected TCP/IP devices. device commands: adb push <local> <remote> - copy file/dir to device adb pull <remote> [<local>] - copy file/dir from device adb sync [ <directory> ] - copy host->device only if changed (-l means list but don't copy) (see 'adb help all') adb shell - run remote shell interactively adb shell <command> - run remote shell command adb emu <command> - run emulator console command adb logcat [ <filter-spec> ] - View device log adb forward <local> <remote> - forward socket connections forward specs are one of: tcp:<port> localabstract:<unix domain socket name> localreserved:<unix domain socket name> localfilesystem:<unix domain socket name> dev:<character device name> jdwp:<process pid> (remote only) adb jdwp - list PIDs of processes hosting a JDWP transport adb install [-l] [-r] [-s] [--algo <algorithm name> --key <hex-encoded key> --iv <hex-encoded iv>] <file> - push this package file to the device and install it ('-l' means forward-lock the app) ('-r' means reinstall the app, keeping its data) ('-s' means install on SD card instead of internal storage) ('--algo', '--key', and '--iv' mean the file is encrypted already) adb uninstall [-k] <package> - 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 backup [-f <file>] [-apk|-noapk] [-shared|-noshared] [-all] [-system|-nosystem] [<packages...>] - write an archive of the device's data to <file>. If no -f option is supplied then the data is written to "backup.ab" in the current directory. (-apk|-noapk enable/disable backup of the .apks themselves in the archive; the default is noapk.) (-shared|-noshared enable/disable backup of the device's shared storage / SD card contents; the default is noshared.) (-all means to back up all installed applications) (-system|-nosystem toggles whether -all automatically includes system applications; the default is to include system apps) (<packages...> is the list of applications to be backed up. If the -all or -shared flags are passed, then the package list is optional. Applications explicitly given on the command line will be included even if -nosystem would ordinarily cause them to be omitted.) adb restore <file> - restore device contents from the <file> backup archive adb help - show this help message adb version - show version num scripting: 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-serialno - prints: <serial-number> adb get-devpath - prints: <device-path> adb status-window - continuously print device status for a specified device adb remount - remounts the /system partition on the device read-write adb reboot [bootloader|recovery] - reboots the device, optionally into the bootloader or recovery program adb reboot-bootloader - reboots the device into the bootloader adb root - restarts the adbd daemon with root permissions adb usb - restarts the adbd daemon listening on USB adb tcpip <port> - restarts the adbd daemon listening on TCP on the specified port networking: adb ppp <tty> [parameters] - Run PPP over USB. Note: you should not automatically start a PPP connection. <tty> 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 [ <directory> ] <localdir> can be interpreted in several ways: - If <directory> is not specified, both /system and /data partitions will be updated. - If it is "system" or "data", only the corresponding partition is updated. environmental variables: ADB_TRACE - Print debug information. A comma separated list of the following values 1 or all, adb, sockets, packets, rwx, usb, sync, sysdeps, transport, jdwp ANDROID_SERIAL - The serial number to connect to. -s takes priority over this if given. ANDROID_LOG_TAGS - When used with the logcat option, only these debug tags are printed.
相关推荐
adb操作命令详解.doc adb操作命令详解.doc
Android中的adb命令详解,Android中的adb命令详解
主要介绍了详解adb shell 常用命令,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
今天小编就为大家分享一篇Python之使用adb shell命令启动应用的方法详解,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧
简介: ... ...3、/dev/input/event3 这个是事件路径。调试发现真机和模拟器事件路径不一样。所以你们在调试看看自己电脑是什么路径 ...5、这个sendevent 事件还可以实现滑动、和多指触屏如果有这样需求在研究。...
android 命令详解!绝对超级有用!
修改/system只读权限,adb shell 命令详解!
前言 本文主要给大家介绍了关于使用Python通过subprocess调用...在电脑上装好adb工具,配置好adb的环境变量,先确保shell中可以调用adb命令。 代码示例 Python2.7 类 Adb,封装了一些adb的方法 import os import sub
ADB全称Android Debug Bridge, 是android sdk里的一个工具, 用这个工具可以直接操作管理android模拟器或者真实的andriod设备(如G1手机). 它的主要功能有: * 运行设备的shell(命令行) * 管理模拟器或设备的端口映射 *...
ARP命令详解
adb(Android Debug Bridge)是Android提供的一个通用的调试工具,说白了就是debug工具。借助这个工具,我们...1、在设备上运行shell命令 2、安装卸载程序 3、推送文件到设备中 4、从设备中推送文件到PC端 5、快速重启
ADB是一个 客户端-服务器端 程序, 其中客户端是你用来操作的电脑, 服务器端是android设备.
启动Shell命令 通过远程Shell端运行Sqllite3连接数据库 UI/软件 试验程序 Monkey 其它的Shell命令 启用Logcat日志 使用Logcat命令 过滤日志输出 控制日志输出格式 查看可用日志缓冲区 查看Stdout 和Stderr Logcat...
四、Monkey 命令详解 1).标准的monkey 命令[adb shell] monkey [options] <eventcount> , 例如:adb shell monkey -v 500 ——–产生500次随机事件,作用在系统中所有activity(其实也不是所有的ac
Android MTU 值修改的...1、首先使用 adb 命令进入系统,然后 ifconfig 查看可用网络 C:\>adb shell $ su su # ifconfig ifconfig lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 UP LOOPBACK
#开始shell命令 adb shell #进入到sdcard卡目录 cd sdcard #将列出所有文件夹 ls #删除文件或文件夹 rm -r (文件夹名称) 您可能感兴趣的文章:Android用ListView显示SDCard文件列表的小例子android读取...
Android学习指南:Android_SDK简介,1. 在Android模拟器上安装和卸载APK包,2. 在Android模拟器上使用sd card生成sdcard镜像文件,启动模拟器,将资源放入到sdcard里面,使用命令adb shell 查看sdcard目录
从Android 6.0(API level 23)开始,Android提出了两个延长电池使用时间的省电特性给用户。用户管理可以在没有充电的情况下管理app的行为。当用户一段时间没有使用手机的时候,Doze模式...我们先用 adb shell dumps