在默認(rèn)情況下adb是通過(guò)USB連接的,但是adb也支持通過(guò)wifi連接,前提是使用adb命令的電腦終端與待調(diào)試的手機(jī)在同一網(wǎng)段下。這樣,在沒(méi)有usb或者遠(yuǎn)程下都可以完成調(diào)試手機(jī)。但是手機(jī)的調(diào)試模式改為wifi后,手機(jī)連接usb就會(huì)無(wú)效,包括充電。可以將手機(jī)在wifi下切回USB即可。
cmd:adb tcpip 5555 //可以斷開(kāi)USB線,此時(shí)會(huì)發(fā)現(xiàn)usb充電無(wú)顯示,連接數(shù)據(jù)線已無(wú)效。//連接wificmd:adb connect android設(shè)備IP地址(如:adb connect 192.168.43.144)//斷開(kāi)wificmd:adb disconnect3.WIIF轉(zhuǎn)為USB(前提adb通wifi連接)
cmd:adb usb//此時(shí)USB數(shù)據(jù)線可以正常使用。4.adb無(wú)連接到WIFI
//需要取得超級(jí)管理員權(quán)限執(zhí)行su,再執(zhí)行setPRop service.adb.tcp.port 5555stop adbdstart adbd//連接wificmd:adb connect android設(shè)備IP地址(如:adb connect 192.168.43.144)5.adb無(wú)連接到USB
//需要取得超級(jí)管理員權(quán)限執(zhí)行su,再執(zhí)行setprop service.adb.tcp.port -1stop adbdstart adbd6.腳本切換
新建一個(gè)文件命名為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直接可以運(yùn)行,windows上需要安裝一些如msysgit或者Cygwin才可運(yùn)行以上Linux shell//前提需要usb連接adb,待執(zhí)行玩命令后,可以拔掉usb數(shù)據(jù)線,此時(shí)手機(jī)切換至wifi連接,待連接上wifi后,如切回至usb,使用adb usb或者重啟設(shè)備即可sh adbTowifi.sh轉(zhuǎn)自:http://www.tuicool.com/articles/rAFnya2
新聞熱點(diǎn)
疑難解答
圖片精選