recently, the company has given a task, the app needs a mobile phone external USB camera, the problem is that the phone outside the other USB devices, the phone can not connect with the PC, can not be on the PC side through Eclipse and other viewing log information, Debugging is particularly troublesome, because even if the program jumps, you do not see log or the cause of the program crashes.
Just one colleague was working on the Linux bottom, and he said it was possible to view the log via wifi adb. It means that the mobile phone through the WiFi and PC side in the same network segment, and then use the ADB command to connect the phone remotely, and then you can wirelessly view the log information on the phone.
This approach requires a necessary condition:
The phone end is in the same network segment as the PC side.
The process is as follows:
- First the phone can be connected to WiFi, so that the phone and the computer are under the same network segment. Notebook say, you can use 360 free WiFi or anything, share a WiFi for mobile phone connection on the line. If it is a desktop computer, and there is no network card, you can buy a small USB external WiFi, plug in the desktop can also share WiFi. (As long as the PC can ping the IP on the phone)
- Check the phone-side connection to the PC side to share out the WiFi after assigning the IP, assuming it is 172.19.10.5, then open the command line on the PC side. Tap command adb connect 172.19.10.5. many times the first case will appear: " Unable to connect to 172.19.10.5:5555 ". What is this for? , because the ADB TCPIP service is not up by default. Many tutorials on the web say Download "terminal emulator" and other similar shell command tools on your phone, using the following command: (Root permission required):
1) SetProp Service.adb.tcp.port 5555 2) Stop ADBD 3) Start adbd
but I use a USB cable to connect the PC, by knocking command adb tcpip 5555, ADB connect 172.19.10.5, will be connected successfully, the phone TCP IP service to start, then you disconnect the USB cable, starting from step 1 to repeat, connected to the WiFi after knocking the ADB connect 172.19.10.5 can be connected successfully. If this is not possible, go to the App store to download a WiFi Abd app and someone else's program will help you get this service up and up.
3. When your adb connect command is successful, you can view the log information via ADB logcat, but this will put all the log information on your phone The full output in the console,
and most of the time we just want to see the log, then we need to filter. For example, ADB logcat *:i will have only log level greater than I for all log information output. Another example is the ADB logcat-s tagname, will be all the name is the tag log information output. or Xu you will not get used to, because we debug an app is to see all the log information of this app, this need to use the grep command, but this grep command only under Linux, So you can either install an Ubuntu or install a Linux instruction set under Windows. I would recommend an Ubuntu virtual machine here, because the Android player will have to be a Linux system at least?
In the Linux shell terminal, you can enter the ADB shell PS, all similar to the Windows process output, see your package name corresponding to the PID, is your app running the PID of the process, and then command adb logcat | grep $pid, it's all right. Other filtering methods can be found in Google, a lot of
Writing is not very good, if you do not understand the message asked me, hope to help you.
View the log information via wifi adb without a USB cable connected to the PC