adb无线如何连接Android真机 adb无线连接手机adb连接手机「adb无线如何连接Android真机 adb无线连接手机」
1.方法一:手机端命令
1.1 手机端打开adb服务,执行命令序列如下:
su
setprop service.adb.tcp.port 5555
stop adbd && start adbd
注明:必须要su,否则start adbd起不来,导致u与wifi都识别不到手机,需要重新启动手机。
1.2 PC端通过WIFI连接手机
C:Userswin10>adb connect 192.168.4.150
connected to 192.168.4.150:5555
注:这一步,有的手机要信任该电脑调试。
C:Userswin10>adb devices
List of devices attached
192.168.4.150:5555 device
1.3 原理如下:
在adb的说明文档中提到:
“An ADB transport models a connection between the ADB server and one device
or emulator. There are currently two kinds of transports:
- U transports, for physical devices through U
- Local transports, for emulators running on the host, connected to
the server through TCP”
大意是说,在物理设备上,adb是通过U连接到设备上的,而在模拟器上,adb是通过TCP协议连接到设备上的。实际上在物理设备上,也可以让adb通过TCP协议来连接设备(当然前提条件是你的设备要有网口)。首先看一下下面这段源代码,出自system/core/adb/adb.c,第921行:
分析上述代码可以发现,在adbd启动时首先检查是否设置了service.adb.tcp.port,如果设置了,就是使用TCP作为连接方式;如果没设置,就去检查是否有adb的U设备(dev/android_adb),如果有就用U作为连接方式;如果没有U设备,则还是用TCP作为连接方式。
因此只需要在启动adbd之前设置service.adb.tcp.port,就可以让adbd选则TCP模式,也就可以通过网络来连接adb了。这需要修改init.rc文件。如果不想修改,也可以在系统启动之后,在控制台上执行以下序列命令
su
setprop service.adb.tcp.port 5555
stop adbd && start adbd
方法二:PC端命令
I discovered this little trick a year ago and it was immensely helpful. So far, whenever I was working on my Android apps, I had to connect it to my laptop with a U cable. The U cable is annoying and limits my movements. Consequently, I was researching, if there is an option to do the debugging over WiFi.
Luckily, there is a super simple way! All you need is a U cable (for the initial setup) and have both devices in the same network. The screenshots in the following section are from my MacBook Pro, but it works on any operating system.
- You need to connect your device to your computer via U cable. Make sure U debugging is working. You can check if it shows up when running
- .
- Run
- Disconnect your device (remove the U cable).
- Go to the Settings -> About phone -> Status to view the IP address of your phone.
- Run
- If you run
Now you can execute adb commands or use your favorite IDE for android development - wireless!
Do I Have to Repeat the Process Every Time?
Now you might ask, what do I have to do when I move into a different work space and change WiFi networks? You do not have to repeat steps 1 to 3 (these set your phone into WiFi-debug mode). You do have to connect to your phone again by executing steps 4 to 6.
Unfortunately, the android phones lose the WiFi-debug mode when restarting. Thus, if your battery died, you have to start over. Otherwise, if you keep an eye on your battery and do not restart your phone, you can live without a cable for weeks!
Happy wireless coding!
方法三:使用adbwireless.apk
今天电脑u接口出问题了,就想着可不可以通过wifi连上手机,然后进行eclipse调试,看logcat等等。
网上搜了一下,果然有这种解决方案。
现在分享给各位Android小伙伴。
前提:需要你的windows电脑已经安装了android sdk。
步骤:
1.关键的东东是需要在你的android手机上安装一个神奇的软件:Adb Wireless (apk下载)
2.在你的手机上安装成功后,图标如图:
3.进入该app,界面如下,点击中间那个很大的按钮,下方会出现连接信息:
4.你需要确保adbWireless这个app获得了你手机的root权限,如果你不确定,可以进入授权管理查看:
5.找到你电脑中安装sdk的地方,运行----->cmd----->cd到sdk目录下的platform-tools目录,
然后敲入第3步中黄色框线框住的内容,我这里是:adb connect 192.168.1.105
当出现connected to字样的时候表明你电脑与手机的无线连接已经成功了,这个时候我们打开eclipse的devices和logcat视图,你会发现真的成功了:
apk wireless.apk 的源码
https://github.com/haikuowuya/adb_wireless
海盐版权声明:本网信息来自于互联网,目的在于传递更多信息,并不代表本网赞同其观点。其原创性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容、文字的真实性、完整性、及时性本站不作任何保证或承诺,并请自行核实相关内容。本站不承担此类作品侵权行为的直接责任及连带责任。如若本网有任何内容侵犯您的权益,请及时联系我们,本站将会在24小时内处理完毕,E-mail:xinmeigg88@163.com