我认为有一种方法可以通过Wi-Fi测试开发中的应用程序。这可能吗?

我希望能够解开我的手机,无线开发。


当前回答

我为Windows写了一个简单的脚本:

步骤1。用以下命令创建一个批处理文件,调用wifi_dedug.bat文件并复制以下内容:

    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

步骤2。将您的设备连接到pc。

步骤3。启动批处理文件(按要求输入键)

步骤4。断开设备连接,通过wifi进行部署/调试。

其他回答

有办法查看Android屏幕远程没有根?- 9号帖子。

通过USB连接设备,并确保调试工作正常; Adb tcpip 5555。这使得设备开始监听端口5555上的连接; 使用adb shell netcfg或adb shell ifconfig(6.0及以上版本)查找设备IP地址; 您现在可以断开USB; adb connect <DEVICE_IP_ADDRESS>:5555。这将连接到我们在步骤2中在设备上设置的服务器; 现在您在网络上有了一个设备,可以像往常一样使用它进行调试。

要将服务器切换回USB模式,请运行adb USB,这将使您手机上的服务器恢复到USB模式。如果您有多个设备,您可以使用-s选项指定设备:adb -s <DEVICE_IP_ADDRESS>:5555 usb。

不需要根!

如果需要查询设备的IP地址,请先执行adb shell命令,再执行netcfg命令。你会在那里看到。 当使用OSX时,可以使用adb shell IP route命令查询IP地址。


警告:启用该选项是危险的,网络中的任何人都可以在调试中连接到您的设备,即使您是在数据网络中。只有连接到可信任的Wi-Fi时才可以这样做,完成后记得断开连接!


@Sergei建议修改第2行,评论道:“当另一个连接持续时(例如,模拟器连接或其他Wi-Fi设备),-d选项需要连接到USB设备”。

这些信息可能对未来的读者很有价值,但我还是回到了得到178个赞的原始版本。


在一些设备上,即使你没有USB线,你也可以做同样的事情:

在开发人员设置中启用网络ADB 它应该显示IP地址 adb connect <DEVICE_IP_ADDRESS>:5555 完成后禁用该设置


使用Android Studio有一个插件,允许您连接USB调试,而不需要从终端使用任何ADB命令。

更新:

从Android Studio Bumblebee(2021.1.1)稳定版开始,你可以通过扫描二维码对设备进行Wifi调试。

引用博客文章:

通过Wi-Fi的ADB: Bumblebee包括一个简化的连接流程 你的Android 11和更高版本的设备通过Wi-Fi进行部署 使用ADB调试。在你的 的“物理”选项卡中选择“使用Wi-Fi动作的对” 新建设备管理器打开配对向导。然后按照下面的步骤 提供用于与通过同一网络连接的设备配对。学习 更多。


老帖:

有了新的Android 11,你可以在WiFi上调试你的应用程序,而完全不需要使用USB线。

引用自Android Studio用户指南

Connect to a device over Wi-Fi (Android 11+) Android 11 and higher support deploying and debugging your app wirelessly from your workstation using Android Debug Bridge (adb). For example, you can deploy your debuggable app to multiple remote devices without physically connecting your device via USB. This eliminates the need to deal with common USB connection issues, such as driver installation. To use wireless debugging, you need to pair your device to your workstation using a pairing code. Your workstation and device must be connected to the same wireless network. To connect to your device, follow these steps: On your workstation, update to the latest version of the SDK Platform-Tools. On the device, enable developer options. Enable the Wireless debugging option. On the dialog that asks Allow wireless debugging on this network?, click Allow. Select Pair device with pairing code. Take note of the pairing code, IP address, and port number displayed on the device (see image). On your workstation, open a terminal and navigate to android_sdk/platform-tools. Run adb pair ipaddr:port. Use the IP address and port number from step 5. When prompted, enter the pairing code that you received in step 5. A message indicates that your device has been successfully paired. none Enter pairing code: 482924 Successfully paired to 192.168.1.130:37099 [guid=adb-235XY] (For Linux or Microsoft Windows only) Run adb connect ipaddr:port. Use the IP address and port under Wireless debugging.

拉杜·西米内斯库的回答对我很管用。谢谢你!对于无法看到android设备ip地址的用户,请转到 >无线> Wi-Fi 然后长按已连接的wifi。然后选择“显示高级选项”上的“修改网络配置检查”,并滚动到IP地址部分。

在系统中安装adb后,请运行 Killadd adb和adb start-server 刷新adb。有时我们会遇到这样的问题

在游戏商店下载应用程序Wifi ADB。非常容易使用,工作就像一个魅力!:)

Windows:

步骤1。使用下面的命令创建一个批处理文件,并将该文件称为w.bat。

步骤2。将下面的内容复制到w.b 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

<--到这里-->

步骤3。用数据线连接你的手机和电脑

步骤4。确保手机处于Wi-Fi模式

第5步。当批处理文件要求您移除电缆时

步骤6。在Windows提示符上输入w.bat (start -> run -> Type 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

注1:在输出中找到这个,(忽略所有->unable to connect<- errors)

connected to xxx.xxx.x.x:9000

如果你在结果中看到这个,只需从PC上移除电缆,进入Eclipse并运行在设备上安装应用程序;应该是这样。

注意2:断开或切换无线模式关闭:键入下面的命令。它应该说在USB模式下重新启动-在这个阶段PC和计算机不应该用电缆连接:

C:\Users\dell>adb usb
restarting in USB mode

注3:查找话机IP地址的步骤(取自Stack Overflow)

查找MY PHONE的IP地址:

a. Dial *#*#4636#*#* to open the Testing menu.
b. In the Wi-Fi information menu: click Wi-Fi Status
c. Wi-Fi status can be blank for the first time
d. Click Refresh Status
e. In the IPaddr: <<IP ADDRESS OF THE PHONE IS LISTED>>

注4:我的手机Wi-Fi连接IP地址范围一般为下面提到的IP地址,

192.168.1.1

192.168.1.2

192.168.1.3

192.168.1.4

192.168.1.5

192.168.1.6

注意5:如果你得到的IP地址序列不断被重新分配给你的手机,你可以在w.b bat文件中修改IP地址。

注意6:这是一种强制方法,它消除了寻找IP地址和连接到Eclipse / Wi-Fi的所有手工劳动。

所以简而言之,常规的活动应该是这样的:

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