我正在尝试在 Motorola Droid 上调试应用程序,但连接到通过 USB 设备。我的开发服务器是在 Hyper-V 中运行的 Windows 7 64 位虚拟机,等等我无法通过访客或主机中的 USB 直接连接。
我安装了几个不同的 USB-over-TCP 解决方案,但自 ADB Monitor反复报“devicemonitor无法启动监控”。有没有办法使用网络而不是 USB 连接或其他可行的选项直接从开发计算机上的客户端连接到设备上的守护程序?
I am attempting to debug an application on a Motorola Droid, but I am having some difficulty connecting to the device via USB. My development server is a Windows 7 64-bit VM running in Hyper-V, and so I cannot connect directly via USB in the guest or from the host.
I installed a couple of different USB-over-TCP solutions, but the connection appears to have issues since the ADB monitor reports "devicemonitor failed to start monitoring" repeatedly. Is there a way to connect directly from the client on the development machine to the daemon on the device using the network instead of the USB connection or possibly another viable options?
发布评论
评论(30)
手动过程
从您的设备(如果已 root)
根据 a post xda-developers,您可以使用以下命令从设备通过 Wi-Fi 启用 ADB:
如果您已经具有 USB访问权限
(无需 root )
如果您已有 USB,则切换到使用 Wi-Fi 会更容易。从通过 USB 连接设备的计算机上的命令行中,发出命令请
务必将
192.168.0.101
替换为实际分配给您的设备的 IP 地址。完成后,您可以通过运行以下命令断开与 adb tcp 会话的连接:您可以通过两种方式查找平板电脑的 IP 地址:
手动 IP 发现:
进入 Android 的 WiFi 设置,单击菜单按钮在操作栏中(垂直省略号),点击高级并在屏幕底部看到 IP 地址。
使用 ADB 发现 IP:
通过 adb 执行以下命令:
告诉 ADB 守护程序返回到通过 USB 进行监听的
应用程序来自动执行该过程
Google Play 上还有多个应用程序可以自动执行此过程。快速搜索后建议使用 adbWireless,< a href="https://play.google.com/store/apps/details?id=com.ttxapps.wifiadb&hl=en" rel="noreferrer">WiFi ADB 和 ADB WiFi。所有这些都需要 root 访问权限,但 adbWireless 需要的权限较少。
Manual Process
From your device, if it is rooted
According to a post on xda-developers, you can enable ADB over Wi-Fi from the device with the commands:
And you can disable it and return ADB to listening on USB with
From a computer, if you have USB access already (no root required)
It is even easier to switch to using Wi-Fi, if you already have USB. From a command line on the computer that has the device connected via USB, issue the commands
Be sure to replace
192.168.0.101
with the IP address that is actually assigned to your device. Once you are done, you can disconnect from the adb tcp session by running:You can find the IP address of a tablet in two ways:
Manual IP Discovery:
Go into Android's WiFi settings, click the menu button in the action bar (the vertical ellipsis), hit Advanced and see the IP address at the bottom of the screen.
Use ADB to discover IP:
Execute the following command via adb:
To tell the ADB daemon return to listening over USB
Apps to automate the process
There are also several apps on Google Play that automate this process. A quick search suggests adbWireless, WiFi ADB and ADB WiFi. All of these require root access, but adbWireless requires fewer permissions.
如果您的手机已root,这非常简单。
从 Google Play 下载终端模拟器(有很多是免费的)。确保您的 Android 设备已连接到 Wi-Fi 并获取 Wi-Fi IP 地址。打开终端程序并输入:
现在转到您的计算机(假设您使用的是 Windows)并在桌面上创建“cmd.exe”的快捷方式(不带引号)。
右键单击 cmd 快捷方式并选择
“以管理员身份运行”
更改为
android-sdk-windows\tools
文件夹类型:
adb 现在应该说你已连接。
注意:如果您太快发出连接命令,则可能会失败。因此,在您说这不起作用之前,请至少尝试两次,每次间隔五秒。
This is really simple if your phone is rooted.
Download a terminal emulator from Google Play (there are lots that are free). Make sure that your Android device is connected to your Wi-Fi and get the Wi-Fi IP address. Open the terminal program and type:
Now go to your computer (assuming that you are using Windows) and create a shortcut on the desktop for "cmd.exe" (without the quotations).
Right click on the cmd shortcut and choose
"Run as Administrator"
Change to your
android-sdk-windows\tools
folderType:
adb should now say that you are connected.
Note: if you are too fast to give the connect command it may fail. So try at least two times five seconds apart before you say this doesn't work.
通过 USB 连接设备并确保调试正常,然后运行:
<前><代码>adb tcpip 5555:5555
adb connect
断开 USB 并继续进行无线调试。
完成后想要切换回 USB 调试,请运行:
要查找设备的 IP 地址,请转至
Settings >无线网络>高级>您设备上的 IP 地址
或运行adb shell netcfg
。无需root。一次只能调试一台设备。
请参阅此 XDA 帖子。
adb
命令位于 Android SDK 的platform-tools
文件夹中。Connect device via USB and make sure debugging is working, then run:
Disconnect USB and proceed with wireless debugging.
When you're done and want to switch back to USB debugging, run:
To find the IP address of your device, go to
Settings > Wi-Fi > Advanced > IP Address
on your device or runadb shell netcfg
.No root required. Only one device can be debugged at a time.
See this XDA post.
The
adb
command is located in theplatform-tools
folder of the Android SDK.假设您将 adb 路径保存到 Windows 环境路径中
在 Android 中激活调试模式
通过 USB 连接到 PC
打开命令提示符类型:
adb tcpip 5555
断开平板电脑或智能手机与电脑的连接
打开命令提示符类型:
adb connect IPADDRESS
(IPADDRESS 是平板电脑或智能手机的 DHCP/IP 地址,您可以通过 Wi-Fi -> 当前连接的网络找到该地址)< /p>现在在命令中提示您应该看到如下结果:connected to xxx.xxx.xxx.xxx:5555
Assume you saved adb path into your Windows environment path
Activate debug mode in Android
Connect to PC via USB
Open command prompt type:
adb tcpip 5555
Disconnect your tablet or smartphone from pc
Open command prompt type:
adb connect IPADDRESS
(IPADDRESS is the DHCP/IP address of your tablet or smartphone, which you can find by Wi-Fi -> current connected network)Now in command prompt you should see the result like: connected to xxx.xxx.xxx.xxx:5555
来自
adb --help
:顺便说一句,这是一个命令行选项。
您应该尝试将手机连接到 Wi-Fi,然后从路由器获取其 IP 地址。它不适用于蜂窝网络。
端口是5554。
From
adb --help
:That's a command-line option by the way.
You should try connecting the phone to your Wi-Fi, and then get its IP address from your router. It's not going to work on the cell network.
The port is 5554.
对于 Windows 用户:
第 1 步:
您必须在 Android 手机中启用开发者选项。
您可以使用这种方式启用开发者选项。
• 打开设置>关于>软件信息>更多。
• 然后点击“版本号”七次以启用开发人员选项。
• 返回“设置”菜单,现在您将能够在那里看到“开发人员选项”。
• 点击它并从下一个屏幕上的菜单中打开“USB 调试”。
第 2 步:
打开 cmd 并输入 adb。
如果您发现 adb 不是有效命令,那么您必须添加环境变量的路径。
•首先进入您的 SDK 安装文件夹
遵循此路径,此路径仅作为示例。
D:\softwares\Development\Andoird\SDK\sdk\platform-tools\;
D:\softwares\Development\Andoird\SDK\sdk\tools;
• 现在搜索Windows系统高级设置
•
打开环境变量。
然后打开路径并粘贴以下路径
这是一个例子。
您的SDK路径与我的不同,请使用您的。 D:\softwares\Development\Andoird\SDK\sdk\platform-tools\;
D:\softwares\Development\Andoird\SDK\sdk\tools;
第 3 步:
打开 cmd 并输入 adb。如果您仍然看到 adb 不是有效命令,则说明您的路径尚未正确设置,请按照上述步骤操作。
现在您可以将您的Android手机连接到PC。
打开cmd并输入adb devices,您就可以看到您的设备。
查找您的手机 IP 地址。
类型:- adb tcpip 5555
获取手机的 IP 地址
,
现在运行您的android 项目,如果没有看到您的设备,请再次输入 adb connect 您手机的 IP 地址
对于 Linux 和 macOS 用户:
第 1 步:打开终端并使用
sudo apt-get install android-tools-adb android-tools-fastboot
安装 adb通过 USB 线将手机连接到 PC。
在终端中输入以下命令
使用adb,连接您的Android手机IP地址。
取出手机。
For Windows users:
Step 1:
You have to enable Developer options in your Android phone.
You can enable Developer options using this way.
• Open Settings> About> Software Information> More.
• Then tap “Build number” seven times to enable Developer options.
• Go back to Settings menu and now you'll be able to see “Developer options” there.
• Tap it and turn on USB Debugging from the menu on the next screen.
Step 2:
Open cmd and type adb.
if you find that adb is not valid command then you have to add a path to the environment variable.
•First go to you SDK installed folder
Follow this path and this path is just for an example.
D:\softwares\Development\Andoird\SDK\sdk\platform-tools\;
D:\softwares\Development\Andoird\SDK\sdk\tools;
• Now search on windows system advanced setting
•
Open the Environment variable.
then open path and paste the following path
this is an example.
You SDK path is different from mine please use yours. D:\softwares\Development\Andoird\SDK\sdk\platform-tools\;
D:\softwares\Development\Andoird\SDK\sdk\tools;
Step 3:
Open cmd and type adb. if you still see that adb is not valid command then your path has not set properly follow above steps.
Now you can connect your android phone to PC.
Open cmd and type adb devices and you can see your device.
Find you phone ip address.
Type:- adb tcpip 5555
Get the IP address of your phone
Now,
Now run your android project and if not see you device then type again adb connect IP address of your phone
For Linux and macOS users:
Step 1: open terminal and install adb using
sudo apt-get install android-tools-adb android-tools-fastboot
Connect your phone via USB cable to PC.
Type following command in terminal
Using adb, connect your android phone ip address.
Remove your phone.
从非 root 设备上的计算机
(请注意,这也可以使用 root 设备来完成,但您可以在不需要 USB 连接的 root 设备上使用 shell)
首先,打开命令提示符 (CMD) 。如果您使用 Android Studio 或 IntelliJ,您可以使用其中包含的控制台。
如果路径中添加了adb,则可以跳过cd部分。
如果可能,打开 SDK 位置,右键单击,然后按“在此处启动命令提示符”。并非所有系统都有此选项,因此您还必须执行此(/这些)命令:
Windows:更改驱动器(如果适用)
并访问 sdk 和平台工具。将此路径替换为您的 SDK 位置:
现在您可以访问 Android 调试桥。
将设备连接到计算机后,执行以下操作:
其中
是您要连接的端口(默认为5555
), 是您要连接的端口(默认为
是您要连接的设备的IP。5555
)。请注意:
5555
是默认端口,只需写入 IP 地址即可连接。如果您使用自定义端口,至少可以提高一点安全性。通过 Wi-Fi 进行 USB 调试可能会被滥用,但前提是该设备连接到想要滥用该设备的计算机。使用非默认端口至少会使连接变得更加困难。如果您使用自定义端口,请确保将其添加在 IP 之后。不写入端口会连接到
5555
,如果您不使用该端口,连接将会失败。您可以通过两种方式查找设备的 IP 地址:
具体名称可能会有所不同,具体取决于您的设备。打开设置并转到关于设备 -> 状态 -> IP 地址
使用 ADB 获取 IP
从控制台,执行以下操作:
一旦完成连接,您就可以断开设备与您的设备的连接。电脑通过这样做:
或者没有IP来断开所有设备。如果您使用自定义端口,则必须指定要断开连接的端口。这里的默认值也是 5555。
要禁用端口(如果这是您想要执行的操作),请在连接的设备上执行以下命令:
或者您可以重新启动设备以删除 tcpip 连接
从 root 设备上的计算机
首先,您需要访问 shell。您可以使用 USB 电缆连接设备并使用
adb shell
,或者从 Google Play、FDroid 或其他来源下载应用程序。然后您可以:
要连接设备,您可以像非 root 版本一样通过执行
adb connect:
来连接设备。如果您想禁用端口并返回 USB 监听:
您还可以使用 Android Studio 插件来为您完成此操作(现在不记得名称了),对于 root 用户,还可以选择下载用于设置手机连接的 Android 应用程序(可能仍需要 adb connect)。
有些手机在开发者选项中有一项设置(这适用于一些未 root 的手机,但也可能是一些已 root 的手机),允许在没有 root 或计算机连接的情况下从设备本身通过 Wi-Fi 切换 ADB开始吧。虽然很少有手机有这个功能
From a computer on a non-rooted device
(Note that this can be done using a rooted device as well, but you can use a shell on a rooted device which doesn't require a USB connection)
Firstly, open command prompt (CMD). If you use Android Studio or IntelliJ there is a console included in there you can use.
If you have adb added to the path, you can skip the cd part.
If possible, open the SDK location, right click, and press "start command prompt here". Not all have this option so you have to do this (/these) commands as well:
Windows: change the drive (if applicable)
And access the sdk and platform tools. Replace this path with your SDK location:
Now you have access to the Android debug bridge.
With the device connected to the computer, do:
Where
<port>
is the port you want to connect to (default is5555
) and<ip>
is the IP of the device you want to connect to.Please note:
5555
is the default port and just writing the IP address connects it. If you use a custom port you can at least improve the security a bit. USB debugging over Wi-Fi can be abused, but only if the device is connected to the computer who wants to abuse the device. Using a non-default port at least makes it a bit harder to connect.If you use a custom port, make sure to add it after the IP. Writing no port connects to
5555
and if you didn't use that the connection will fail.You can find the IP address of a device in two ways:
Depending on your device, the exact names may vary. Open settings and go to About device -> Status -> IP address
Use ADB to get the IP
From the console, do:
And once you are finished with the connection, you can disconnect the device from your computer by doing:
Or no IP to disconnect all devices. If you used a custom port, you must specify which port to disconnect from. The default is 5555 here as well.
To disable the port (if that is something you want to do) you do this command with the device connected:
Or you can restart the device to remove the tcpip connection
From a computer on a rooted device
Firstly, you need access to the shell. You either connect the device using a usb cable and use
adb shell
or download an app from Google Play, FDroid, or some other source.Then you do:
And to connect the device, you do as in the non-rooted version by doing
adb connect <ip>:<port>
.And if you want to disable the port and go back to USB listening:
You can also use an Android Studio plugin to do it for you (don't remember the name right now), and for rooted users there's also the option of downloading an Android app to set up the phone connection (adb connect is probably still required).
Some phones have a setting in developer options (this applies to some unrooted phones, though probably some rooted phones too) that allows for toggling ADB over Wi-Fi from the device itself without root or a computer connection to start it. Though there are few phones that have that
我需要让 USB 和 TCPIP 都能为 ADB 工作(不要问),所以 执行了以下操作(使用其他人从 xda-developers 发布的说明) :
我使用
adb shell
I needed to get both USB and TCPIP working for ADB (don't ask), so I did the following (using directions others have posted from xda-developers)
Using
adb shell
:使用 TCP 端口连接平板电脑。
确保您的系统和设备连接到同一网络。
adb tcpip 5555
adb connect 192.168.1.2
这是您的设备 IP 地址使用端口转发连接
尝试进行端口转发,
adb forward tcp:
tcp:如下:
如果您收到消息错误:找不到设备,请将 USB 设备连接到系统,然后按照相同的步骤操作。
对于已取得 root 权限的设备
To connect your tablet using TCP port.
Make sure your system and device is connected to same network.
adb tcpip 5555
adb connect 192.168.1.2
this is your device IP addressConnected using port forward
Try to do port forwarding,
adb forward tcp:
<PC port>
tcp:<device port>
like:
If you get message error: device not found connect a usb device to system then follow same procedure.
for a rooted device
我不知道如何在没有任何 USB 连接的情况下连接设备,但如果您设法在另一台计算机上连接它,您可以通过从
终端发出命令将 adbd 切换到 TCP 模式,并从任何 PC 通过 wifi 连接到您的设备在网络上:
也许还可以从设备上的终端切换到 TCP 模式。
I do not know how to connect the device without any USB connection at all, but if you manage to connect it maybe at another computer you can switch the adbd to TCP mode by issuing
from a terminal and connect to your device over wifi from any PC on the network by:
Maybe it is also possible to switch to TCP mode from a terminal on the device.
首先,您必须通过 USB 连接您的设备,
然后将您的设备连接到 WIFI 并获取 IP 地址。
当仍然通过 USB 连接时,在命令行中或通过 Android Studio 终端键入此内容,
您将看到这些消息:
现在移除 USB 电缆,您仍然会看到 logcat 正常
完成。享受
First you must connect your device via USB
Then connect your device to WIFI and get the IP address.
While still connect via usb type this in command line or via Android Studio Terminal
You will see these messages:
Now remove the USB cable and you will still see your logcat as normal
Done. Enjoy
如果您想轻松连接设备以通过 WiFi 运行、调试或部署 Android 应用程序,您可以使用我开发的开源 IntelliJ 插件。 这里是代码,这里插件可供使用。
使用方法非常简单。这里有一个 gif:
If you want to easily connect your device to run, debug or deploy your Android apps over WiFi you can use an open source IntelliJ Plugin I've developed. Here is the code and here the plugin ready to be used.
The usage is quite simple. Here you have a gif:
正如布莱恩所说:
它有效。您只需要访问 android shell 并输入这些命令...
市场上还有另一种(更简单的)解决方案:adbWireless,它会自动设置您的手机。
需要root!对于两个...
As Brian said:
It works.You just need to access the android shell and type those commands...
One other (easier) solution is on the Market: adbWireless, it will automatically set your phone.
Root is required! for both...
很奇怪,但这仅适用于我连接了 USB 电缆的情况,然后我可以拔下 USB 并与其他所有 adb 一起使用。
返回 USB 时也是如此,
仅当 USB 连接时才有效。
并不重要
我是否发出or
then stop & 。启动 adbd,我仍然需要 USB 电缆,否则它不起作用。
因此,如果我的 ADB over USB 无法工作,我打赌我也无法启用 ADB over WiFi。
Weird, but this only works for me if I have the USB cable connected, then I can unplug the usb and go for it with everything else adb.
and the same when returning to usb,
will only work if usb is connected.
It doesn't matter if I issue the
or
then stop & start adbd, I still need the usb cable in or it doesn't work.
So, if my ADB over usb wasn't working, I bet I wouldn't be able to enable ADB over WiFi either.
要仅使用一个命令在 TCP 和 USB 模式之间切换,您可以将其添加到
/init.rc
:现在您可以使用属性
service.adb.tcp.enable
来启用或禁用端口 5555 上的侦听。运行netstat
检查其是否正在侦听。正如您所看到的,如果您确实希望手动更改service.adb.tcp.port
,它也会触发。To switch between TCP and USB modes with just one command, you can add this to
/init.rc
:And now you can use property
service.adb.tcp.enable
to enable or disable listening on port 5555. Runnetstat
to check whether it's listening. As you can see it will also trigger if you do wish to changeservice.adb.tcp.port
manually.Bash 实用函数:
Bash util function:
步骤 1.
确保您的 adb 主机和 Android 设备两者位于同一 Wifi 网络上。
步骤 2.
使用 USB 数据线将 Android 设备与计算机连接。一旦执行此操作,您的主机将检测您的设备,并且 adb 将开始在计算机上以 USB 模式运行。您可以使用
adb devices
检查连接的设备,同时通过执行adb usb
确保adb正在USB模式下运行。步骤 3.
使用以下命令以 tcpip 模式重新启动 adb:
步骤 4.
找出 Android 设备的 IP 地址。有几种方法可以做到这一点:
$ adb shell netcfg
。现在您知道了设备的 IP 地址,请将 adb 主机连接到它。
步骤 5.
拔下 USB 电缆,您应该已连接到您的设备。如果您在
adb devices
中没有看到它,则只需使用上一步的命令重新连接:要么您现在就可以开始,要么您需要通过执行
adb 来终止您的 adb 服务器Kill-server
并再次执行所有步骤。希望有帮助!
参考:
STEP 1.
Make sure both your adb host computer and Android device are on the same Wifi network.
STEP 2.
Connect the Android device with the computer using your USB cable. As soon as you do that, your host computer will detect your device and adb will start running in the USB mode on the computer. You can check the attached devices with
adb devices
whereas ensure that adb is running in the USB mode by executingadb usb
.STEP 3.
Restart adb in tcpip mode with this command:
STEP 4.
Find out the IP address of the Android device. There are several ways to do that:
$ adb shell netcfg
.Now that you know the IP address of your device, connect your adb host to it.
STEP 5.
Remove the USB cable and you should be connected to your device. If you don’t see it in
adb devices
then just reconnect using the previous step’s command:Either you’re good to go now or you’ll need to kill your adb server by executing
adb kill-server
and go through all the steps again once more.Hope that helps!
Reference:
这些是我遵循的步骤,它对我有用,
These are the steps I followed and it worked for me,
您还可以使用 SSH 本地端口转发。但它仍然涉及 USB 电缆。使用 USB 将手机连接到运行 sshd 的计算机(主机)。在远程(来宾)电脑上启动具有端口转发/隧道功能的 SSH 客户端。示例:
我使用此结构将我的设备连接到虚拟机。 Eltima USB 转以太网不够稳定(调试期间超时)。
SSH 隧道免费且更可靠。
You can also use SSH local port forwarding. But it still involves a USB cable. Connect your phone using USB to a computer (host) with an sshd running. On a remote (guest) pc start an SSH client capable of portforwarding/tunneling. Example:
I use this construction to connect my device to a virtual machine. Eltima USB to Ethernet wasn't stable enough (timeouts during debug).
SSH tunneling works for free and is more reliable.
我发现其他答案令人困惑。使用 adbWireless 更简单:
http://ppareit.github.com/AdbConnect/
只需安装一个应用程序在您的手机上通过 wifi 切换调试,安装 eclipse 插件即可完成。
I find the other answers confusing. Far simpler to use adbWireless:
http://ppareit.github.com/AdbConnect/
Simply install an app on your phone to toggle debugging over wifi, install an eclipse plug-in and you're done.
我整理了一个批处理文件,用于通过 TCP 自动启用 ADB 并将其连接到通过 USB 连接的设备。有了它,您不必手动输入 IP。
I put together a batch file for automatic enabling and connecting ADB via TCP, to a device connected via USB. With it you don't have to put in the IP manually.
以下是使用蓝牙对 Brian 的答案进行的扩展:
在 Linux 上,使用 Blueman 通过蓝牙与您的设备共享 PC 互联网:
使用蓝牙网络执行 ADB 命令:
<前><代码>$ adb tcpip 5555
$ adb connect $(adb shell ip -f inet addr show bt-pan | egrep -o '[0-9]+\.[0-9]+\.[0-9]+\.[0-9] +' | 头 -n1):5555
完成后返回 USB 模式:
注意:蓝牙 3.0 和 4.0 的速度可达 24 Mbit/s。
Here's an extension to Brian's answer using Bluetooth:
On Linux, use Blueman to share PC internet with your device via Bluetooth:
Use the Bluetooth network for ADB commands:
Once done to return to USB mode:
Note: Bluetooth 3.0 and 4.0 can go up to 24 Mbit/s.
步骤:
su
-- 切换到超级用户。setprop service.adb.tcp.port 5555
- 指定 tcp 端口 - 5555 是此处的端口号stop adbd
- 停止 adbd 服务。start adbd
- 启动 adbd 服务。这与我的 Windows PC 上的
ssh
完美配合,我尝试在我的氰基手机上启动时执行此操作,或使用 plink 启动它。使用 plink,我无法使用 su 权限启动 shell ... sudo 或 su 命令不起作用。启动时我不知道它是如何工作的!
我的 shell 程序通过 ssh 运行
su -c "sh /storage/sdcard1/start_adb.sh"
以及最后 3 个命令(不带 su --)谢谢
Steps :
su
-- To switch to super user.setprop service.adb.tcp.port 5555
- To specify the tcp Port - 5555 is the port number herestop adbd
- To stop the adbd service.start adbd
- To start adbd service.this works perfectly with
ssh
from my windows PCI try to do this on the boot on my cyanogen mobile or launch this with plink. With plink I can't launch shell with su right ... sudo or su command not works. On boot I don't know how it's works!
My shell program works from ssh with
su -c "sh /storage/sdcard1/start_adb.sh"
with the last 3 commands (without su --)Thanks
另一项注意事项(经过惨痛教训):您不应该同时激活您公司的 VPN 连接...
One additional note (learned the hard way): You should not have your company VPN-connection active at the same time...
您需要执行以下操作:
You Need to do following things:
有两种方法可以通过 TCP 连接 Android 设备与 ADB?
第一种方法
按照以下步骤操作
以上命令的输出在
上面的命令的帮助下,您将找到所连接设备的IP地址
上面的命令将重新启动这个TCP端口:5555
第二种方式
您可以使用 Android Studio 插件
Android device with ADB
Android WiFi ADB - IntelliJ/Android Studio 插件
请查看这篇文章以获取更多信息
在 Android Studio 中将 Android 设备连接到 Wifi
There are two ways to connect your Android device with ADB over TCP?
First way
Follow this steps
OUTPUT of above command
With the help you above command you will find the IP Address of connected device
The above command will restart this TCP port: 5555
Second way
You can use Android Studio Plugin
Android device with ADB
Android WiFi ADB - IntelliJ/Android Studio Plugin
Please check this article for more information
Connect Android Device with Wifi within Android Studio
我正在解决同样的问题,但是
一个简单的黑客
adb 反向 tcp:; tcp:
为我工作。它允许系统接受 TCP 请求。感谢您的阅读
I'm struct at the same issue but
a simple hack
adb reverse tcp:<PORT> tcp:<PORT>
worked for me. It allows the system to accept tcp requests.Thank You for reading
使用 adbwireless 应用程序启用手机,然后从 Windows 计算机使用 adb connect 与其通信。手机上的 adbwireless 应用程序会告诉您如何连接到它,并提供 IP 地址和所有信息。
不太有趣的替代方案是通过 USB 连接,告诉手机通过 adb tcpip 5555 使用 TCPIP,然后断开 USB,然后使用 adb connect。这要困难得多,因为这样你必须自己找出手机的 IP 地址(adbwireless 告诉你 IP),你必须通过 USB 连接,并且你必须运行 adb tcpip(adbwireless 也会处理这个问题)。
因此:在您的手机上安装 adbwireless。使用它。有可能,我经常在 Linux 和 Windows 上这样做。
Use the adbwireless app to enable the phone, then use adb connect from the Windows machine to talk to it. The adbwireless app on the phone tells you how to connect to it, giving the IP address and everything.
The much less fun alternative is to connect via USB, tell the phone to use TCPIP via adb tcpip 5555, then disconnect USB, then use adb connect. This is much harder because this way you have to figure out the IP address of the phone yourself (adbwireless tells you the IP), you have to connect via USB, and you have to run adb tcpip (adbwireless takes care of that too).
So: install adbwireless on your phone. Use it. It is possible, I do it routinely on Linux and on Windows.
在我的系统上,情况是这样的:
在我的 Android 设备上的 Linux shell 中,一个简单的“ifconfig”并没有给我我的 IP 地址。我必须输入:
ifconfig eth0
- 或 -
netcfg
才能获取我的 IP 地址。 (我知道 eth0 已配置,因为我在 dmesg 中看到了它。)然后我执行了:
setprop service.adb.tcp.port -1
stop adbd
start adbd
然后在我的 Win7 机器上(运行 Eclipse 3.7.1 的机器)。我打开了命令提示符
\android-sdk\platform-tools>;
无需以管理员身份运行。然后我做了
adb connect 12.345.678.90
我从来没有放过端口。如果我执行了
adb tcpip 5555
它说找不到设备,那么我的“adb devices”列表中什么也没有出现。也就是说,只有当我不执行上面的 tcpip 命令时它才有效。
我可以做一个“adb shell”并搞乱我的 Android 设备。但我的 Android 设备现在没有出现在我的“运行”->“运行配置”->“目标”选项卡中。另一方面,如果我将目标选项卡设置为自动。然后,当我通过“运行”->“运行”运行我的应用程序时,它确实在我的 Android 设备上运行,即使我的 Android 设备甚至没有被列为我的目标之一。
On my system it went like this:
On my Android device in my Linux shell, a simple "ifconfig" did not give me my IP address. I had to type:
ifconfig eth0
-or-
netcfg
to get my IP address. (I knew eth0 was configured because I saw it in my dmesg.) Then I did the :
setprop service.adb.tcp.port -1
stop adbd
start adbd
Then on my Win7 box (the one running Eclipse 3.7.1). I opened a command prompt to
\android-sdk\platform-tools>
without running as admin. Then I did a
adb connect 12.345.678.90
I never put a port. If I did a
adb tcpip 5555
it said it couldn't find the device then nothing appeared in my "adb devices" list. I.e. it only works if I DON'T do the tcpip command above.
I can do an "adb shell" and mess with my Android Device. But my Android Device does not appear in my Run->Run Configurations->Target tab right now. On the other hand, if I keep the Target Tab set to automatic. Then when I run my app via Run->Run it does run on my Android device even though my Android device is not even listed as one of my targets.
我确实让这个工作了。没有使用任何 USB 电缆。
运行它。这将设置 ip 和端口;然后在dos中
连接。
I did get this working. Didn't use any usb cable.
Run it. That will set ip and port; Then in dos
Connected.