1.簡介
在默認情況下adb是通過USB連接的,但是adb也支持通過wifi連接击你,前提是使用adb命令的電腦終端與待調試的手機在同一網(wǎng)段下娱据。這樣仅叫,在沒有usb或者遠程下都可以完成調試手機。但是手機的調試模式改為wifi后彻舰,手機連接usb就會無效伐割,包括充電∪谢剑可以將手機在wifi下切回USB即可隔心。
2.連接USB線轉為WIFI(前提adb通過usb連接)
cmd:adb tcpip 5555//可以斷開USB線,此時會發(fā)現(xiàn)usb充電無顯示尚胞,連接數(shù)據(jù)線已無效济炎。//連接wificmd:adb connect android設備IP地址(如:adb connect 192.168.43.144)//斷開wificmd:adb disconnect
3.WIIF轉為USB(前提adb通wifi連接)
cmd:adb usb//此時USB數(shù)據(jù)線可以正常使用。
4.adb無連接到WIFI
//需要取得超級管理員權限執(zhí)行su辐真,再執(zhí)行setprop service.adb.tcp.port 5555stopadbdstartadbd//連接wificmd:adbconnectandroid設備IP地址(如:adbconnect192.168.43.144)
5.adb無連接到USB
//需要取得超級管理員權限執(zhí)行su须尚,再執(zhí)行setprop service.adb.tcp.port -1stopadbdstartadbd
6.腳本切換
新建一個文件命名為adbTowifi.sh
#!/bin/bash#Modify this with your IP rangeMY_IP_RANGE="192\.168\.43"#You usually wouldn't have to modify thisPORT_BASE=5555#List the devices on the screen for your viewing pleasureadb devicesecho#Find USB devices only (no emulators, genymotion or connected devicesdeclare-adeviceArray=(`adb devices-l| grep -v emulator | grep -v vbox | grep -v"${MY_IP_RANGE}"| grep" device "| awk'{print $1}'`)echo"found${#deviceArray[@]}device(s)"echoforindexin${!deviceArray[*]}doecho"finding IP address for device${deviceArray[index]}"IP_ADDRESS=$(adb-s${deviceArray[index]}shell ifconfig wlan0 | awk'{print $3}')echo"IP address found :$IP_ADDRESS"echo"Connecting..."adb-s${deviceArray[index]}tcpip $(($PORT_BASE+$index))adb-s${deviceArray[index]}connect"$IP_ADDRESS:$(($PORT_BASE + $index))"echoechodoneadb devices-l#exit
//以上腳本文件,mac或者Linux直接可以運行侍咱,windows上需要安裝一些如msysgit或者Cygwin才可運行以上Linuxshell//前提需要usb連接adb耐床,待執(zhí)行玩命令后,可以拔掉usb數(shù)據(jù)線楔脯,此時手機切換至wifi連接撩轰,待連接上wifi后,如切回至usb昧廷,使用adb usb或者重啟設備即可shadbTowifi.sh