Unity prints debugging log of Android apk error

environment

1. Turn on the debugging mode on your Huawei phone:

Click [Settings] | [About Phone] | [Version Number] three times.
Insert image description here
2. Unity3d environment settings:

[File]|[Building Settings] Enable the necessary options (only to view the log on the console, other options are not required; if you want to connect to Unity's profiler, you must select all development options):

  • Development Build
  • Script Debugging
    Insert image description here

Connect Android phone

1. USB connection to Android phone.

2. [Edit] | [Preferences] | [External Tools] Find the Android path of Android Sdk . Enter the Sdk Install Path/platform-tools directory, and in this directory, open the cmd command window (it is recommended to install Git Bash , right-click Git Bash to open it directly).

3. Check the connected devices and make sure the computer is connected to the phone.

./adb.exe devices  

Insert image description here
4. After executing the log listening command in the window, run the apk on the mobile phone :

# 参数 unity 表示只打印 unity 相关的日志, E 表示不可解决的错误。

# window
./adb.exe logcat -s Unity 

# git bash 只看 error 日志
./adb.exe logcat -s Unity | grep "E Unity" --color

Insert image description here

grep is a command provided by the git bash tool. The cmd that comes with window does not have this command.

Unity3d Profile

【window】|【Analysis】| 【Profier】
Insert image description here

appendix

[1] Logcat command line tool

Guess you like

Origin blog.csdn.net/WGYHAPPY/article/details/127991968