adb logcat on a real phone using tcp/ip

匿名 (未验证) 提交于 2019-12-03 03:12:02

问题:

Can I dump logs from an android phone over wifi (using tcp/ip) using adb? adb connect can be used, but it needs some server to be running on the phone (at 5555 port). How do I start this server? Or the only way to get logs from a phone is by connecting it as a USB device?

回答1:

Install adbWireless on your phone. Run the application and click on the big button (you cannot miss it!). It will activate ADB over Wifi and display the URL to use to connect to it with the adb command.

On your computer, run the adb command with the connect parameter. The usage for adb says:

 connect <host>[:<port>]       - connect to a device via TCP/IP                                  Port 5555 is used by default if no port number is specified. 

Obviously the computer and the smartphone must be on the same Wifi network.



回答2:

zero4

All you are trying to do is drop adb logcat command on the device & send output stream to a remote location. I would suggest, read this post about how to run shell commands in your app.

The summary is

  • Run "adb logcat"
  • Collect Output Stream of the command in a file on device
  • & Finally post that file to your local server OR Manually pull that file from device

The post contains link to everything you are looking for.



回答3:

Android is very paranoid when it comes to network access. Without root access, you can't really run any servers, just clients. In short, without root, look at the answer from 100rabh.

If you do have root, you could either open up your network stack for incoming connections on port 5555, or you could hack adb to do the inverse connection (that is, connect to your client). The latter is way more secure and shouldn't really be to hard to do. (I haven't looked at the code for a while, though.) The communication bits for all parts of adb is handled in one and the same library, for all three parts of adb (server, daemon and client).

By the way, what you refer to as a server on the phone is really the adb daemon.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!