Android中ADB用法总结

来源:互联网 发布:备案是域名还是空间 编辑:程序博客网 时间:2024/06/06 08:38

1、设置环境变量

1)查看主目录并在主目录创建.bash_profile文件

echo $HOME

touch .bash_profile

2)打开文件并输入下面一行

open -e .bash_profile

export PATH=/Users/shixin/Library/Android/sdk/platform-tools/:$PATH

3)关闭文件并验证

执行source .bash_profile让文件修改立即生效

命令行执行adb,不显示-bash: adb: command not found,即说明设置正确。

2、无线调试Android APP

输入adb查看帮助信息

1)USB连接设备,然后查看

adb devices

List of devices attached

TWGDU16704004944device

2)设置手机WiFi监听端口

adb tcpip 5555

多个设备要指定序列号,否则error: more than one device/emulator

adb -s TWGDU16704004944 tcpip 5555

restarting in TCP mode port: 5555

未USB连接会显示error: no devices/emulators found

3)手机跟电脑连接相同wifi,查看手机ip,并执行如下命令

adb connect 192.168.19.56

connected to 192.168.19.56:5555

断开连接用adb disconnect 192.168.19.12

adb usb从TCP切换USB模式

3) adb服务关闭和启动

adb kill-server

adb start-server

4)电脑端和手机端传输文件

adb pull /sdcard/yiche.realm /Users/shixin/Desktop/

adb push /Users/shixin/AndroidStudioProjects/android-autoEasy-gradle/out_apks/android-autoEasy-c18-debug.apk /sdcard/Download/

5)安装\卸载\启动APK

adb shell pm install -r "/sdcard/Download/com.yiche.autoeasy"

adb shell pm uninstall -k com.yiche.autoeasy

清除数据

adb shell pm clear com.yiche.autoeasy

启动APP

adb shell am start -n com.yiche.autoeasy/.ADActivity

6)获取手机信息

重启手机

adb reboot

adb reboot bootloader/recovery

查看mac地址、CPU信息、内存信息、设备信息,IP地址,序列号

adb shell cat /sys/class/net/wlan0/address|/proc/cpuinfo|/proc/meminfo|/system/build.prop

adb shell netcfg

adb shell ifconfig rmnet0

adb get-serialno

查看CPU和内存占用

adb shell top

adb shell top -m 6

adb shell top -n 1

查看进程列表和后台服务

adb shell ps

adb shell service list

0 0
原创粉丝点击