码迷,mamicode.com
首页 > 数据库 > 详细

adb命令 简单总结

时间:2015-01-15 22:09:34      阅读:241      评论:0      收藏:0      [点我收藏+]

标签:

1、向android设备获取或存储文件(执行命令之前不需要adb shell)
adb pull:拉出来,即拷贝文件出来
eg:adb pull /mnt/sdcard/test.apk D:\
adb pull /mnt/sdcard/test.apk D:\a.apk

adb push:推进去,即拷贝文件进去

eg:adb push D:\a.apk /mnt/sdcard/
  adb push D:\a.apk /mnt/sdcard/b.apk
  
2、卸载和安装apk(执行命令之前需要先执行adb shell,因为命令需要shell来解析)
adb uninstall [-k] <pkg>   -k参数:keep the data and cache directories.即保存数据

eg:adb uninstall com.demo.pkg

pm uninstall [-k] <pkg>

adb install <path>

eg:adb install /mnt/sdcard/b.apk

注意:安装之前需要先卸载,不然install不会成功。

3、清除apk数据(执行命令之前需要先执行adb shell,因为命令需要shell来解析)
pm clear <pkg>
eg:pm clear com.demo.pkg

4、截屏(执行命令之前需要先执行adb shell,因为命令需要shell来解析)
screencap <path> 将截图保存至path目录下(设备的目录)
screencap /mnt/sdcard/img.png

5、通过包名和类名打开apk(执行命令之前需要先执行adb shell,因为命令需要shell来解析)
am start -a android.intent.action.MAIN -n pkgName/ActName ActName可以是决定包名也可以是相对于pkgName的相对包名
eg:am start -a android.intent.action.MAIN -n com.android.settings/.Settings
or:am start -a android.intent.action.MAIN -n com.android.settings/com.android.settings.Settings

6、网络adb
连接目标设备:adb connect IP:Port
eg:adb connect 192.168.196.39:5555
连接成功后,操作就跟设备通过usb接口连接电脑一样的操作

7、查看当前连接了多少个设备
adb devices

8、选择某个设备作为目标设备,如果当前连接了多个设备的情况下,单独执行命令的话,会出现more than one device and emulator的问题,
这个时候就要用-s参数选择一个设备作为目标设备.
adb -s [deviceName] 命令
eg:adb -s emulator-5554 uninstall com.demo.pkg

9、查看log打印
9.1 打印当前所有的log,没有过滤器
adb logcat 
9.2 通过TAG来过滤获取log
通过管道用grep过滤,指定正则表达式
adb logcat | grep "[-e] TAG" 
eg:adb logcat | grep "-e MainActivity"

adb命令 简单总结

标签:

原文地址:http://blog.csdn.net/android_dong/article/details/42747263

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!