简体   繁体   English

Android - 通过wifi连接到带adb的设备

[英]Android - Connecting to device with adb over wifi

Context: Nexus 7 Android device (NOT Rooted), Android Studio, Mac OS Yosemite 10.10 Swapping between Eclipse environment and the Android studio appears to have caused the problem, But I don't know how to repair it. 上下文:Nexus 7 Android设备(未植入),Android Studio,Mac OS Yosemite 10.10 Eclipse环境和Android工作室之间的交换似乎已经引起了问题,但我不知道如何修复它。 All attempts below are after the Eclipse has been shutdown and both computer and device rebooted. 下面的所有尝试都是在Eclipse关闭并且计算机和设备都重新启动之后。

Have seen quite a few SO entries but none resolve the intermittent issue of the dreaded 'helpful' message 'unable to connect to 192.168.xx.xx' 已经看到了不少SO条目,但没有解决可怕的'有用'消息“无法连接到192.168.xx.xx”的间歇性问题

It will work successfully sometimes, then "pop" can't connect via wireless Connection. 它有时会成功运行,然后“pop”无法通过无线连接进行连接。 One suggestion I saw was to disconnect the USB after the adb tcpip 5555 command. 我看到的一个建议是在adb tcpip 5555命令后断开USB连接。 This worked for me for a while. 这对我来说有一段时间了。 But not currently! 但目前不是!

Have also have tried reboot (computer and device... this has helped before) 也试过重启(计算机和设备......这有帮助)

Have tried invoking adb tcpip 7612 this alternate port different port This gives me either 'unable to connect to 192.168.xx.xx:5555' OR 'unable to connect to 192.168.xx.xx:7612:7612' 试过调用adb tcpip 7612这个备用端口不同的端口这给我“无法连接到192.168.xx.xx:5555”或“无法连接到192.168.xx.xx:7612:7612”

Android docs suggest adb kill-server. Android文档建议使用adb kill-server。 And to repeat the steps, Still get the 'helpful' message 'unable to connect to 192.168.0.4' 要重复这些步骤,仍然会收到“有用”消息“无法连接到192.168.0.4”

I have tried specifying that the Nexus use wireless from the Nexus itself (using a terminal app), although I am uncertain if these commands are taking affect as the device is not rooted. 我已经尝试指定Nexus使用Nexus本身的无线(使用终端应用程序),虽然我不确定这些命令是否会因为设备未植根而生效。 setprop service.adb.tcp.port 5555 stop adbd start adbd setprop service.adb.tcp.port 5555 stop adbd start adbd

Any help in determining what causes the intermittent nature of this connectivity would be greatly appreciated. 任何帮助确定导致这种连接的间歇性的原因将不胜感激。 Thanks 谢谢

Your problem seems related to the ADB process started by your IDE. 您的问题似乎与IDE启动的ADB过程有关。 If you want to be sure your ADB connection is working as should and you don't have any error in the commands you are executing I recommend you to use one IntelliJ/Android Studio plugin I've developed to connect your device to your computer over WiFI. 如果您想确保您的ADB连接正常工作,并且您正在执行的命令中没有任何错误,我建议您使用我开发的一个IntelliJ / Android Studio插件,将您的设备连接到您的计算机上无线上网。 Here is the code and here the plugin ready to be used. 是代码, 这里准备使用插件。

In the following gif you can see how it works: 在下面的gif中,您可以看到它是如何工作的:

在此输入图像描述

I have now managed to connect. 我现在设法连接。

Connect both the android device and the mac to a router that does NOT perform Wifi isolation. 将android设备和mac连接到不执行Wifi隔离的路由器。 Confirmed that the device was connected to the router on the network, AND that I could ping the android device from my mac book. 确认设备已连接到网络上的路由器,并且我可以从我的mac书中ping Android设备。

Then using the following steps: (step - explanation) Plug the device into the Mac, with the developer options USB debugging enabled. 然后使用以下步骤:(步骤 - 说明)将设备插入Mac,启用开发人员选项USB调试。 (Goto Settings/About Tablet, tap on the build number 7 times, until developer options enabled. Then enable the "USB debugging" option within this new area. You may need to google enabling USB debugging for your device) (转到设置/关于平板电脑,点击内置版本号7次,直到启用开发人员选项。然后启用此新区域中的“USB调试”选项。您可能需要谷歌启用设备的USB调试)

Start Android Studio - goto the terminal. 启动Android Studio - 转到终端。 Navigate (cd command) to the location where you installed the sdk. 导航(cd命令)到您安装sdk的位置。 (This can be hidden by mac so you may need to start a mac terminal and run "chflags nohidden ~/Library") (这可以被mac隐藏,所以你可能需要启动一个mac终端并运行“chflags nohidden~ / Library”)

adb kill-server - make sure the server is dead adb usb - start adb in usb mode adb kill-server - 确保服务器已经死了adb usb - 在usb模式下启动adb

  • make sure you are watching your device, you may need to acknowledge the usb debugging request. 确保您正在观看您的设备,您可能需要确认usb调试请求。
  • 2 reasons you may not see the "Allow USB debugging", you have checked the "Always allow from this computer" OR there are times it does not show, reason unknown. 您可能没有看到“允许USB调试”的2个原因,您已经选中了“始终允许来自此计算机”或有时它没有显示,原因未知。 If this happens - retry above 2 steps and make sure you confirm the "Allow USB debugging" 如果发生这种情况 - 重试2步以上并确保确认“允许USB调试”

You will get one of the following messages: * daemon not running. 您将收到以下消息之一:*守护程序未运行。 starting it now on port xxxx * * daemon started successfully * restarted in USB mode - OR last line will be error: device unauthorized. 现在在端口xxxx上开始* *守护进程成功启动*在USB模式下重启 - 或最后一行将是错误:设备未经授权。 Please check the confirmation dialog on your device. 请检查设备上的确认对话框。 (if you get the error, retry it) (如果收到错误,请重试)

adb tcpip 5555 - make sure to acknowledge "Allow USB debugging" again Return message: restarting in TCP mode port: 5555 adb tcpip 5555 - 确保再次确认“允许USB调试”返回消息:在TCP模式下重启端口:5555

Make sure you know what the ip address of your device is. 确保您知道设备的IP地址是什么。 (pull down on the wifi in the action bar, click on the connected network to get the list then click on the connected entry, should give you a status including the current ip address) (在操作栏中下拉wifi,点击连接的网络获取列表然后点击连接的条目,应该给你一个状态,包括当前的IP地址)

Now unplug your device from the Mac, run the following command with the ip gathered above. 现在从Mac上拔下您的设备,使用上面收集的IP运行以下命令。 adb connect 192.168.xx Acknowledge the "Allow USB debugging" again. adb connect 192.168.xx再次确认“允许USB调试”。 Return message should be: connected to 192.168.xx 返回消息应该是:连接到192.168.xx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM