美文网首页
adb shell 命令

adb shell 命令

作者: 阿飞666666 | 来源:发表于2019-11-16 13:30 被阅读0次

      adb ( Android Debug Bridge)是一个通用命令行工具,其允许您与模拟器实例或连接的 Android 设备进行通信。它可为各种设备操作提供便利,如安装和调试应用。

adb 常用命令

1.查看版本:adb version。

2.查看设备信息:adb advices。

3. 查看设备上面安装的应用包名:adb shell pm list packages

3.在设备安装apk:adb install | -r <apkName>  -r 覆盖原安装文件 -s 可以指定设备。

例如:#默认安装:adb install "C:\Users\lufei\Desktop\ifenqu.apk"

          # 覆盖安装:adb install -r  "C:\Users\lufei\Desktop\ifenqu.apk"

          # 指定设备安装:adb  -s  d08bea53 install  "C:\Users\lufei\Desktop\ifenqu.apk"

4. 卸载apk

1.首先进入设备的/data/app目录找到app包名

adb shell

cd /data/app/

2.执行命令删除

adb uninstall  | -k  <apkName>  卸载软件

adb uninstall  com.ifenqu.app

Tips:安装后的包名系统会在末尾加上-1之类的数字,要去掉才可以成功卸载。 软件名称为包名,不要包含.apk

-k 加 -k 参数,为卸载软件但是保留配置和缓存文件。

5. 文件读取

1. 将文件从PC写入到设备

adb push <local> <remote>

例如:adb push C:\Users\lufei\Desktop\kyb.txt /sdcard

2. 将文件从设备读取到PC

adb pull <remote> <local>

例如:adb pull /sdcard/server.log  C:\Users\lufei\Desktop

注意:由于权限问题,不能直接pull到电脑磁盘根目录,否则会报错。

6. 屏幕截图

adb shell screencap /sdcard/screen.png

例如:adb pull /sdcard/screen.png  C:\Users\lufei\Desktop

7.adb服务启动和关闭

adb kill-server :关闭adb 服务

adb start-server: 开启adb 服务

注意:Tips:如果5037端口被占用可以使用如下命令释放端口

netstat -ano | findstr "5037"

8.aapt解析包信息

aapt dump badging /Users/macbook/Desktop/app.apk

aapt d badging packagename

8、有apk的情况下查看activity

8.1 aapt dump xmltree **.apk AndroidManifest.xml

aapt dump xmltree  /Users/macbook/Desktop/app-dev_V2.7.0_b7fa168_2018-11-16_16-22.apk AndroidManifest.xml

8.2 使用apktool 反编译,反编译后打开AndroidManifest.xml文件

apktool d ***.apk

8.3 aapt dump badging **.apk |findstr "package"

aapt dump badging **.apk |findstr "launchable-activity"

9、无apk已经安装的应用

9.1.logcat

清除logcat内容,使用命令adb logcat -c

启动logcat,使用命令adb logcat ActivityManager:I *:s

启动要查看的程序,

9.2.dumpsys

启动要查看的程序;

命令行输入:adb shell dumpsys window w |findstr / |findstr name=

adb官方参考文献:https://developer.android.com/studio/command-line/adb.html

参考文献:https://www.jianshu.com/p/cc45a25c44c0

相关文章

网友评论

      本文标题:adb shell 命令

      本文链接:https://www.haomeiwen.com/subject/gdryictx.html