Location>code7788 >text

LogCat connects to Android phones to pull logs locally (Unity dev version)

Popularity:627 ℃/2024-08-03 11:10:27

When developing a game in unity, you will often encounter errors/crashes on your Android phone, and to locate the problem, you need to pull the logs from your Android phone and view them on your computer.

1. unity installation, check the Android module (sdk these remember to check the installation)

2. Open the adb directory under the corresponding Android module directory, currently my installation directory is C:\Program Files\Unity\Hub\Editor\2021.3.32f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\platform- tools. tools

3. cmd command line into this directory, call to open adb to execute the command (it is recommended to install cmder, added to the system environment by default, right-click under the folder to open)cmder(i.e. default into the directory, than cmd to omit their own command cd into the folder step, please download the full version)

 

4. android phone open usb debugging mode, the phone into the system information, version information, more than a few points to know the developer options, enter the developer options to open the usb debugging mode, connect to the computer, will be prompted whether to allow usb debugging, the motor can be allowed.

5. Execute the command: adb logcat -v time > wait a few minutes, occasionally F5 refresh the file manager, check whether from 0kb to xxkb. wait a period of time, disconnect the phone cable, open the file to view the corresponding crash time point of the log, you can search for the Unity keyword to filter out the log information is not related to unity, the system log is too much to affect the efficiency of the view. The system log is too much to affect the efficiency of viewing, if it is sdk and other logs that have nothing to do with unity, you can search the logs according to the corresponding package name/keyword of the sdk, and then view the logs one by one in the area corresponding to the time point if you don't have it.