209 字
1 分钟
ADB 使用
2022-06-07

ADB#

安装#

已安装Android SDK:

export PATH=$PATH:/path/to/Android/sdk/platform-tools

不安装Android SDK:

$ brew install android-platform-tools

通过WLAN连接#

Android 11以上:

$ adb pair ipaddr:port $ adb connect ipaddr:port

Android11以下:

先连接USB

$ adb tcpip <port>

随后可以断开USB连接

$ adb connect ipaddr:port

查看已连接设备#

$ adb devices -l

停止daemon#

$ adb kill-server

指定设备#

$ adb devices

List of devices attached
emulator-5555 device

$ adb -s emulator-5555 install /path/to/some.apk

不会引起歧义时,也可以-e指定模拟器,-d指定物理设备。

端口转发(设备端口给主机访问)#

$ adb forward tcp:port tcp:port

顺序: LOCAL REMOTE

反向代理(主机端口给设备访问)#

$ adb reverse tcp:port tcp:port

顺序: REMOTE LOCAL

复制文件#

$ adb pull /remote/path /local/path

$ adb push /local/path /remote/path

Shell#

$ adb shell

安装应用#

$ adb install /local/path/to/some.apk

$ adb shell pm install /device/path/to/some.apk

卸载应用#

$ adb uninstall <pkg_name>

$ adb shell pm uninstall <pkg_name>

截图#

$ adb shell screencap /sdcard/demo.png

录屏#

$ adb shell screenrecord /sdcard/demo.mp4

logcat#

$ adb logcat -b all -v color '*:D'

ADB 使用
https://shsuco.com/posts/adb使用/
作者
shsuco
发布于
2022-06-07
许可协议
CC BY-NC-SA 4.0