通过Wi-Fi运行/安装/调试Android应用程序?
我认为有一种方法可以通过Wi-Fi测试开发中的应用程序。这可能吗通过Wi-Fi运行/安装/调试Android应用程序?,android,debugging,adb,wifi,Android,Debugging,Adb,Wifi,我认为有一种方法可以通过Wi-Fi测试开发中的应用程序。这可能吗 我希望能够解除手机连接并进行无线开发。adb实用程序确实能够通过TCP/IP连接到设备。但是,adbd通常不会侦听TCP连接 如果您想让它运行,您需要一个工程设备(换句话说,您需要root)。然后按照本帖中的说明进行操作: 因为这只适用于eng设备,所以官方不支持。使用风险自负,可能会出现错误等。请参阅论坛帖子 通过USB连接设备,确保调试正常 adb tcpip 5555。这使得设备开始监听端口5555上的连接 使用6.0及更
我希望能够解除手机连接并进行无线开发。adb实用程序确实能够通过TCP/IP连接到设备。但是,adbd通常不会侦听TCP连接 如果您想让它运行,您需要一个工程设备(换句话说,您需要root)。然后按照本帖中的说明进行操作: 因为这只适用于eng设备,所以官方不支持。使用风险自负,可能会出现错误等。请参阅论坛帖子
adb tcpip 5555
。这使得设备开始监听端口5555上的连接李>
adb shell netcfg
或adb shell ifconfig
查找设备IP地址李>
adb connect:5555
。这将连接到我们在第2步在设备上设置的服务器李>
adb USB
,这将使手机上的服务器返回USB模式。如果您有多个设备,可以使用-s
选项指定设备:adb-s:5555 usb
不需要根目录
要查找设备的IP地址:运行
adb shell
,然后运行netcfg
。你会在那里看到的。
要在使用OSX时查找IP地址,请运行命令adb shell IP route
警告:启用该选项很危险,即使您在数据网络中,网络中的任何人都可以连接到调试中的设备。仅在连接到受信任的Wi-Fi时执行此操作,并记住在完成后断开连接
@Sergei建议修改第2行,并评论道:“-d选项需要在其他连接持续时连接到USB设备(例如,emulator连接或其他Wi-Fi设备)” 这些信息可能对未来的读者很有价值,但我还是回到了获得178票的原始版本
在某些设备上即使没有USB电缆,您也可以执行相同的操作:
adb connect:5555
使用Android Studio,您可以连接USB调试,而无需从终端使用任何ADB命令。如果您想在设备上启用无线ADB,而无需连接USB电缆(需要root):
ip addr show
然后在调试环境中运行以下命令:
adb connect ip.of.the.device
这将使设备作为您可能拥有的任何其他模拟器列出。请注意,TCP将保持打开状态,直到您重置设备。
如果经常出现断开连接的情况,您可能还需要安装Wi-Fi保持活动应用程序
如果你想感到安全,记得在连接到公共网络时关闭TCP。您可以执行以下操作或简单地重新启动设备:
ip addr show
最好的方法是使用ADBConnect(插件)和ADB Wireless(Android设备应用程序)。对于Windows: 第一步。使用以下命令创建一个批处理文件,并调用该文件
w.bat
第二步。在w.bat
中复制以下内容,并将其保存在Windows系统的%path%
中的任何文件夹中
echo ***Get phone in Wi-Fi mode***
echo ***Get phone in Wi-Fi mode***
adb devices
echo ***Remove cable from the phone now***
adb tcpip 9000
adb connect 192.168.1.1:9000
adb connect 192.168.1.2:9000
adb connect 192.168.1.3:9000
adb connect 192.168.1.4:9000
adb connect 192.168.1.5:9000
adb connect 192.168.1.6:9000
//
第三步。用电缆连接手机和电脑
第四步。确保手机处于Wi-Fi模式
第五步。当批处理文件要求您删除电缆时,请删除电缆
第六步。在Windows提示符下键入w.bat
(开始->运行->键入CMD
,按Enter键)(黑屏是Windows DOS提示符),如果您将其复制到其中一个路径文件夹中,则可以从任何位置运行,否则从创建此文件的文件夹运行
批处理文件的输出如下:
C:\Windows\System32>w
C:\Windows\System32>echo ***Get phone in Wi-Fi mode***
***Get phone in Wi-Fi mode***
C:\Windows\System32>echo ***Get phone in Wi-Fi mode***
***Get phone in Wi-Fi mode***
C:\Windows\System32>adb devices
List of devices attached
d4e9f06 device
C:\Windows\System32>echo ***Remove cable from the Phone now***
***Remove cable from the Phone now***
C:\Windows\System32>adb tcpip 9000
restarting in TCP mode port: 9000
C:\Windows\System32>adb connect 192.168.1.1:9000
unable to connect to 192.168.1.1:9000:9000
C:\Windows\System32>adb connect 192.168.1.2:9000
connected to 192.168.1.2:9000
C:\Windows\System32>adb connect 192.168.1.3:9000
unable to connect to 192.168.1.3:9000:9000
C:\Windows\System32>adb connect 192.168.1.4:9000
unable to connect to 192.168.1.4:9000:9000
C:\Windows\System32>adb connect 192.168.1.5:9000
unable to connect to 192.168.1.5:9000:9000
C:\Windows\System32>adb connect 192.168.1.6:9000
unable to connect to 192.168.1.6:9000:9000
Step 1. Connect PC and Wi-Fi via a cable
Step 2. Start CMD - to go to Windows DOS prompt
Step 3. Type "w"
Step 4. Find connected command in the output
Step 5. Success, remove cable and start using Eclipse
注1:在输出中找到这个,(忽略所有->无法连接我找到了我的答案:
$ adb usb
restarting in USB mode
$ adb devices
List of devices attached
######## device
$ adb tcpip 5555
restarting in TCP mode port: 5555
设置->关于平板电脑->状态->IP地址
。记住IP地址,其形式为。#。#。
有时无法找到android设备的IP地址,如我的情况。因此,您可以使用adb获得它,如下所示:
$adb shell netcfg
结果应该在结果的最后一行$ adb connect #.#.#.#
connected to #.#.#.#:5555
$ adb devices
List of devices attached
#.#.#.#:5555 device
adb kill-server
$ adb connect #.#.#.#
connected to #.#.#.#:5555
$ adb devices
List of devices attached
#.#.#.#:5555 device
adb kill-server
#!/usr/bin/env bash
#Notice: if unable to connect to [ip]:5555,
#try adb kill-server then try again.
adb shell ip route > addrs.txt
#Case 1:Nexus 7
#192.168.88.0/23 dev wlan0 proto kernel scope link src 192.168.89.48
#Case 2: Smartsian T1,Huawei C8813
#default via 192.168.88.1 dev eth0 metric 30
#8.8.8.8 via 192.168.88.1 dev eth0 metric 30
#114.114.114.114 via 192.168.88.1 dev eth0 metric 30
#192.168.88.0/23 dev eth0 proto kernel scope link src 192.168.89.152 metric 30
#192.168.88.1 dev eth0 scope link metric 30
ip_addrs=$(awk {'if( NF >=9){print $9;}'} addrs.txt)
echo "the device ip address is $ip_addrs"
echo "connecting..."
rm addrs.txt
adb tcpip 5555
adb connect "$ip_addrs"
adb tcpip 5555
pause
adb shell "ip addr show wlan0 | grep 'inet ' | cut -d' ' -f6|cut -d/ -f1" > tmpFile
pause
set /p ip= < tmpFile
@echo %ip%
del tmpFile
@echo %ip%
adb connect %ip%
pause
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew cask install android-platform-tools
adb devices
$> adb devices // check all usb debuggable devices connected.
$> adb -d shell // Access device shell.
shell> ifconfig // Check and copy wifi ip-address eg:192.168.1.90
shell> exit // Exit from android device shell.
$> adb tcpip 5000 // open TCP port 5000 (or any available)
$> adb connect 192.168.1.90:5000 // connect to device via wifi ip over specific TCP port.
$> adb devices // you will get debuggabled android device over wifi.
adb connect <device_ip_address>:5555
first you shold connect your device with usb to pc after that run cmd and drag and drop adb.exe that is in sdk/platform-tools path and write below code :
....\Sdk\platform-tools\adb.exe devices
.....\Sdk\platform-tools\adb.exe tcpip 5555
.....\Sdk\platform-tools\adb.exe connect Ip address:5555
adb tcpip 5555
adb connect $(adb shell ifconfig | grep "inet " | grep -v 127.0.0.1 | awk '{print $2}' | cut -d: -f2):5555
none
Enter pairing code: 482924
Successfully paired to 192.168.1.130:37099 [guid=adb-235XY]
adb pair 192.168.XXX.XXX:XXXX <--------- the address showing on screen under paring code
adb connect 192.168.XXX.XXX:XXXX <--- this address shows inside wireless debug menu