ADB、Wifi 和 Eclipse:如何配置?
最近我发现可以使用WIFI而不是USB调试方法来调试应用程序开发。我进行了搜索,发现了一个名为 abdWireless 的应用程序,但我有一个问题。
我如何告诉 Eclipse 通过 Wifi 方法连接?
我认为这是一个自动过程,但在开始调试时它会打开模拟器。
有人吗? :) 再见
Recently I see that is possible to debug app development by use WIFI instead of USB debug method. I make a search and I found an app called abdWireless but I have a problem.
How I can tell to Eclipse to connect via Wifi method?
I think that it is an automatic process, but on start debug it open the Emulator.
Someone? :)
Bye
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
首先,从控制台/终端运行“adb connect ip:port”,例如
adb connect
(使用您的 IP 地址和端口)。这使得adb
服务通过网络连接到您的设备。如果不指定端口号,则默认使用端口 5555。
然后检查设备是否正确连接:从控制台/终端运行
adb devices
(确保从设备上拔下 USB 电缆)。如果adb devices
没有列出您的设备,那么您会遇到一些完全不同的问题。如果您已通过
adb
连接设备,并且可以在adb devices
列表中看到该设备,但您的eclipse仍然启动模拟器,:Target
选项卡并选择Manual
每次从 Eclipse 启动应用程序时,都会弹出设备选择。因此,您将能够明确指定要使用的模拟器/设备。
要断开您的设备,请
adb断开
First, run 'adb connect ip:port', like
adb connect <phone-ip-address>
, from console/terminal (with your IP address and port of cause). This makesadb
service to connect to your device via network.Port 5555 is used by default if no port number is specified.
Then check that device is correctly connected: run
adb devices
from console/terminal (make sure you remove usb cable from device). Ifadb devices
does not list your device, then you have some entirely different issue.If you've connected your device via
adb
and you can see the device inadb devices
list, but your eclipse still starts emulator,:Target
tab and selectManual
This will popup device selection each time you start the app from eclipse. So you will be able to explicitly state which emulator/device to use.
To disconnect your device,
adb disconnect <phone-ip-address>
可以使用 Adb Connect 在 Eclipse 中自动执行此过程:
http://ppareit.github.com/AdbConnect/
This process can be automated from within Eclipse with Adb Connect:
http://ppareit.github.com/AdbConnect/
我将尝试解释如何在我的 win7 x32 上通过 adb 通过 wifi 将 eclipse 与我的 Android 设备连接起来,同时共享我的互联网连接。
我正在使用两种方法。
第一个是当我的计算机连接到互联网(即通过以太网电缆),并且我通过 WiFi(如热点)与我的 Android 设备共享此连接时。
当我的计算机未直接连接到互联网,但我正在使用我的设备的互联网将我的计算机连接到互联网时,我会使用第二个。
请注意,要使其工作,您的无线卡必须满足某些要求,因为这不适用于所有无线卡。
首先,您需要从计算机共享您的互联网连接。为此,请使用管理权限打开 cmd(命令提示符)(按 win 徽标,键入 cmd,然后按 ctrl+shift+enter )。要设置“热点”,请键入:
将“热点”更改为您希望调用 ssid 的任何名称。将“D2D46784ECB32”更改为您想要的密钥 (WPA2)。
现在,转到控制面板\网络和 Internet\网络连接。您可能会注意到一个名为“无线网络连接 2”的新“适配器”。右键单击以太网连接(或用于连接到互联网的任何设备)。单击属性。点击分享。选中“允许其他网络用户通过此计算机的 Internet 连接进行连接”。选择无线网络连接 2. 单击“确定”。您刚刚所做的就是启动 Internet 连接共享 (ICS)。
下一步是将您的设备连接到刚刚创建的连接。在您的 Android 设备上,搜索 wifi 连接,您可以通过您设置的 ssid(即热点)找到该连接,然后输入您设置的密钥(即 D2D46784ECB32)。建立连接后,您就可以访问互联网了。
请注意,有时我会遇到此连接问题。有时我的设备无法连接(我认为win7有bug)。我通常通过转到我的计算机连接来解决此问题,在我的以太网连接上,我转到属性→共享,取消选中“允许其他...”。单击“确定”。然后再次转到该连接的属性→共享并选中“允许其他...”。基本上我已经重置了ICS。现在我通常能够连接。
另请注意,一旦您重新启动计算机,我很可能必须重新启动托管网络并重置 ICS。
要停止热点,请键入:
要启动热点,请键入:
请注意,您不必再次设置托管网络,只需启动它即可。另请注意,您必须处于 netsh - wlan 模式(像以前一样,键入 netsh,然后键入 wlan),并且必须以管理权限启动 cmd。
现在,如果您还没有这样做,请打开 Android 设备中的开发人员选项并通过网络打开 ADB。之后您很可能会看到一个 IP 地址,后缀为
ie.:
192.168.137.158:5555
在计算机上,打开 cmd,转到 adt/sdk/platform-tools 文件夹。在我的电脑上,它是这样的:
并输入以下内容:
您应该将 IP 地址替换为 Android 设备开发人员选项中显示的 IP 地址。 (我不需要添加 :5555 后缀/端口,但您可能需要这样做)。
要检查连接是否成功,请键入:(
顺便说一句,我要感谢 inazaruk 对此的帮助)。
现在,您应该能够通过 wifi 连接 eclipse 与您的 Android 设备,正如其他人所解释的那样(运行配置 → 目标 → 手册)。
在您的 Android 设备上,转至设置 → 更多 → 网络共享和便携式热点 → 设置 wi-fi 热点。根据需要更改 SSID、密钥和安全性。
返回上一步并打开便携式 Wi-fi 热点。
在您的计算机上,使用您设置的 ssid 和密钥,通过 wifi 连接到您的 Android 设备,就像连接任何其他 wi-fi 连接一样。
连接后,转至控制面板\网络和 Internet\网络连接,右键单击您刚刚连接的无线连接。选择状态,然后选择详细信息。找到您计算机的 IPv4 地址(至少我使用的是 IPv4,您可能使用 IPv6)。
该地址可能是这样的:
192.124.159.52
默认网关应该是这样的:
192.124.159.1
在您的计算机上,打开 cmd,转到您的 adt/sdk/platform-tools 文件夹。在我的计算机上,它是这样的:
并输入以下内容:
您应该将 IP 地址替换为显示的默认网关地址(我不需要添加 :5555 后缀/端口,但您可能需要这样做)。
要检查连接是否成功,请输入:(
顺便说一句,我想再次感谢 inazaruk)。
现在,您应该能够通过 wifi 连接 eclipse 与您的 Android 设备,正如其他人所解释的那样(运行配置 → 目标 → 手册)。
我必须承认我还没有尝试过这个选项,但我猜它与之前的两种方法类似。在开发者选项中找到 Android 设备的 IP 地址(当您通过网络启用 ADB 时应该能够看到它)。然后在您的计算机上,像以前一样:
打开 cmd,转到您的 adt/sdk/platform-tools 文件夹。在我的计算机上,它是这样的:
并输入以下内容:
。
要检查连接是否成功,请输入:
现在,您应该能够通过 wifi 连接 eclipse 与您的 Android 设备,正如其他人所解释的那样(运行配置 → 目标 → 手动)。
现在,我知道这并不完全是问题的答案。但我确实发现很难共享我的互联网连接,然后使用 wifi 和 eclipse 来开发应用程序。一段时间后,我成功地按照我所描述的方式进行连接。所以,如果我帮助别人做同样的事情,我会很高兴:-)
I'll try to explain how I connected eclipse with my android device with adb thru wifi on my win7 x32, sharing my internet connection at the same time.
I'm using two methods.
The first one is when my computer is connected the internet (ie. thru ethernet cable), and I'm sharing this connection with my android device thru wifi (like a hotspot).
The second one I use when my computer isn't connected directly to the internet, yet I'm using my device's internet to connect my computer to the internet.
Note that for this to work, your wireless card must meet certain requirements, as this won't work with all wireless cards.
Well first of all, you need to share your internet connection from your computer. To do that open cmd (command prompt) with administrative privileges (press the win logo, type cmd, and then press ctrl+shift+enter). To set up the "hotspot", type:
Change "Hotspot" to whatever you want your ssid to be called. Change "D2D46784ECB32" to whatever you want your key (WPA2) to be.
Now, go to Control Panel\Network and Internet\Network Connections. You'll probably notice a new "adapter" called "Wireless Network Connection 2". Right click on the ethernet connection (or whatever device you use to connect to the internet). Click on properties. Click on sharing. Check the "Allow other network users to connect through this computer's Internet connection". Select the Wireless Network Connection 2. Click OK. What you just did was to start Internet Connection Sharing (ICS).
The next step is to connect your device to the connection you've just created. On your Android device, search the wifi connection, which you'll find by the ssid you've set (ie. Hotspot), and enter the key you've set (ie. D2D46784ECB32). Once the connection has been established, you'll have Internet access.
Please note that sometimes I have trouble with this connection. Sometimes my device is unable to connect (I think that there is a bug in win7). I usually fix this by going to my computers connections, and on my ethernet connection I go to properties → sharing, uncheck the "Allow other...". Click OK. Then again go to that connection's properties → sharing and check the "Allow other…". Basically I've reset the ICS. And now I'm usually able to connect.
Please also note that once you've restarted your computer, I'll most probably have to restart the hostednetwork and reset the ICS.
To stop the hotspot, type:
To start the hotspot, type:
Note that you don't have to set the hostednetwork again, just start it. Please also note that you must be in the netsh - wlan mode, (type netsh and then wlan, as before), and the cmd must have been started with the administrative privileges.
Now, if you haven't already done it, turn on your developer options in your android device and turn on ADB over network. After that you'll most likely see an ip address, suffixed by
ie.:
192.168.137.158:5555
On your computer, open cmd, go to your adt/sdk/platform-tools folder. On my computer it's like this:
And type the following:
You should replace the ip address with the one that was shown in your android device in the developer options. (I didn't need to add the :5555 suffix/port, but you may need to do it).
To check whether the connection was successful, type:
(Btw, i'd like to thank inazaruk for his help with this).
Now, you should be able to connect eclipse with your android device thru wifi, as others have explained (run configuration → target → manual).
On your Android device, go to Settings → More → Tethering and portable hotspot → Set up wi-fi hotspot. Change the SSID, the key and the security as you please.
Go back one step and turn on Portable Wi-fi Hotspot.
On your computer, connect to your android device via wifi as you'd do with any other wi-fi connection, with the ssid and key that you've set.
Once you've connected, go to Control Panel\Network and Internet\Network Connections, right-click on the wireless connection you've just connected to. Select Status and then Details. Find the IPv4 address of your computer (at least I'm using IPv4, you might use IPv6).
That address might be like this:
192.124.159.52
The default gateway should then be like this:
192.124.159.1
On your computer, open cmd, go to your adt/sdk/platform-tools folder. On my computer it's like this:
And type the following:
You should replace the ip address with the one that was shown default gateway (I didn't need to add the :5555 suffix/port, but you may need to do it).
To check whether the connection was successful, type:
(Btw, i'd like to thank inazaruk again for this).
Now, you should be able to connect eclipse with your android device thru wifi, as others have explained (run configuration → target → manual).
I must admit that I haven't tried this option, but I'm guessing that it's similar as the two methods before. Find the IP address of the android device in the developer options (you should be able to see it when you enable ADB over network). And then on your computer, as before:
open cmd, go to your adt/sdk/platform-tools folder. On my computer it's like this:
And type the following:
.
To check whether the connection was successful, type:
Now, you should be able to connect eclipse with your android device thru wifi, as others have explained (run configuration → target → manual).
Now, I know that this isn't exactly the answer to the question. But I did find it very hard to share my internet connection, and then to use the wifi with eclipse to develop apps. After some time, I managed to connect like I've described. So, if I've helped someone to do the same, I'd be very happy :-)