android adb 相关命令

来源:互联网 发布:比较好的java培训机构 编辑:程序博客网 时间:2024/05/16 06:52

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

0 0