悉野小楼

导航

apk常用命令

查看设备列表

adb devices

 
# 1. 上传(你已经执行了的)

adb push E:\apk\new2.apk /data/local/tmp/aaa.apk

 

# 2. 安装
adb shell pm install /data/local/tmp/aaa.apk

 

# 3. 删除临时APK文件
adb shell rm /data/local/tmp/aaa.apk

# 卸载app

adb uninstall com.example.app
 

导出日志到文件

adb logcat -v time > log.txt

 


查看设备列表

adb devices

通过 IP 连接设备(Wi-Fi 调试)

adb tcpip 5555
adb connect 192.168.0.101:5555

断开连接

adb disconnect 192.168.0.101:5555

应用管理

安装 APK(保留数据覆盖安装)

adb install -r app.apk

卸载应用

adb uninstall com.example.app

清除应用数据与缓存

adb shell pm clear com.example.app

系统与界面操作

启动 Activity

adb shell am start -n com.example.app/.MainActivity

强制停止应用

adb shell am force-stop com.example.app

模拟按键事件(如返回键)

adb shell input keyevent 4

模拟点击与滑动

adb shell input tap 500 800
adb shell input swipe 300 1000 300 500

调试与日志

实时查看日志

adb logcat

按级别过滤日志(仅错误)

adb logcat *:E

导出日志到文件

adb logcat -v time > log.txt

屏幕与文件操作

截图并保存到本地

adb exec-out screencap -p > screen.png

录制屏幕(限制 180 秒)

adb shell screenrecord /sdcard/demo.mp4
adb pull /sdcard/demo.mp4

文件传输

adb push local.txt /sdcard/local.txt
adb pull /sdcard/remote.txt ./remote.txt

实用技巧

获取设备信息

adb shell getprop ro.product.model
adb shell getprop ro.build.version.release

查看当前前台 Activity

adb shell dumpsys activity top | findstr ACTIVITY

posted on 2026-05-21 12:02  悉野  阅读(21)  评论(0)    收藏  举报