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

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


当前回答

当你按照上面的答案https://stackoverflow.com/a/10236938/6117565,你可能会得到错误“没有路由到主机”。

要解决这个问题,在上述回答的第5步之前,首先启动模拟器,然后尝试连接设备。不知道发生了什么,但这个把戏奏效了。

其他回答

更新:

从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.

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

只需下载谷歌ADB: https://developer.android.com/studio/releases/platform-tools 提取并利用它。 例如,配对:

./adb pair 192.168.8.90:42119 274678

然后连接:

./adb connect 192.168.8.90:38995

例如使用scopy这样的软件:

export ADB="/home/luca/Downloads/platform-tools/adb"
scrcpy

(不需要根)有一个最好的,简单的和Android Studio的UI方法

IntelliJ和Android Studio插件创建快速连接您的Android设备通过WiFi安装,运行和调试您的应用程序没有USB连接。按下一个按钮,就不用管USB线了。

只需安装插件Android WiFi ADB

直接下载安装Android WiFi ADB

Intellij / Android Studio:首选项/设置->插件->浏览库

.

记住!第一次初始化设备,您必须使用usb连接

或者,您也可以从JetBrains插件站点下载插件并手动安装:Preferences/Settings->Plugins->从磁盘安装插件。

您可以轻松连接和管理您的设备.......更多信息请阅读这里https://github.com/pedrovgs/AndroidWiFiADB

最好的方法是使用ADBConnect (Eclipse插件)和ADB Wireless (Android设备应用程序)。