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

android adb 相关命令

2016-11-22 15:42 337 查看

android adb 相关命令

android 5.0以上获取电池信息

adb shell dumpsys batterystats

http://www.2cto.com/kf/201510/445482.html

显示系统相关信息

adb shell cat /system/build.prop

显示手机型号

adb shell cat /system/build.prop | grep build.version.sdk

显示cpu使用情况

adb shell top -n 1 -d 0.5

显示具体包名app的cpu使用情况

adb shell top -n 1 -d 0.5 | grep com.xx.xx

显示app内存使用情况

adb shell dumpsys meminfo com.xx.xx |grep “TOTAL”

日志打印

adb logcat

-v time 显示时间

-s tag1 tag2 tag3 显示不同tag日志

adb logcat -v time -s AndroidRuntime

安装卸载app

adb install xxx/xxx/xxx.apk

adb uninstall com.xxx.xxx

启动app

adb start com.xxx.xxx/xxx.xxx.xxx.xxxactivity

查找build.gradle文件里面的版本号

cat build.gradle | grep versionCode |awk '{print $2}'
cat build.gradle | grep versionName |awk '{print $2}'


杀掉进程测试程序被杀掉的闪退

adb shell am force-stop com.example.packagename

如果你有多个进程,可以在第二栏找到进程 id(PID)(如,下面第一个数字):

adb shell ps | grep com.example.packagename

然后这样杀掉:

adb shell kill PID

点击100,300的坐标

adb shell input tap 100 300

输入字符串,需要editext有焦点

adb shell input text hello

截图命令

adb shell /system/bin/screencap -p /sdcard/screentest.png

拉取图片命令

adb pull /sdcard/screentest.png /Users/lds/testtttt.png

模拟长按home(组合命令,home数值是102)

adb shell sendevent /dev/input/event0 1 102 1

adb shell sendevent /dev/input/event0 0 0 0

adb shell sleep 3

adb shell sendevent /dev/input/event0 1 102 0

adb shell sendevent /dev/input/event0 0 0 0
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  android shell