在默認情況下adb是通過USB連接的,但是adb也支持通過wifi連接,前提是使用adb命令的電腦終端與待調試的手機在同一網段下。這樣,在沒有usb或者遠程下都可以完成調試手機。但是手機的調試模式改為wifi后,手機連接usb就會無效,包括充電。可以將手機在wifi下切回USB即可。
cmd:adb tcpip 5555 //可以斷開USB線,此時會發現usb充電無顯示,連接數據線已無效。//連接wificmd:adb connect android設備IP地址(如:adb connect 192.168.43.144)//斷開wificmd:adb disconnect3.WIIF轉為USB(前提adb通wifi連接)
cmd:adb usb//此時USB數據線可以正常使用。4.adb無連接到WIFI
//需要取得超級管理員權限執行su,再執行setPRop service.adb.tcp.port 5555stop adbdstart adbd//連接wificmd:adb connect android設備IP地址(如:adb connect 192.168.43.144)5.adb無連接到USB
//需要取得超級管理員權限執行su,再執行setprop service.adb.tcp.port -1stop adbdstart adbd6.腳本切換
新建一個文件命名為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 -a deviceArray=(`adb devices -l | grep -v emulator | grep -v vbox | grep -v "${MY_IP_RANGE}" | grep " device " | awk '{print $1}'`) echo "found ${#deviceArray[@]} device(s)"echofor index in ${!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才可運行以上Linux shell//前提需要usb連接adb,待執行玩命令后,可以拔掉usb數據線,此時手機切換至wifi連接,待連接上wifi后,如切回至usb,使用adb usb或者重啟設備即可sh adbTowifi.sh轉自:http://www.tuicool.com/articles/rAFnya2
|
新聞熱點
疑難解答