Unity Log adb debugging and Android Logcat debugging (graphic detailed version)

Table of contents

1. Use adb to open Unity log debugging on Huawei mobile phones 

1. Turn on the developer option USB debugging of the mobile phone. .

2. Use the data cable to connect the mobile phone and the computer.

3. Find the adb debugging tool under Unity, as shown below:

4. Open adb 

5. ADB test

 Two, Android Logcat debugging display log


1. Use adb to open Unity log debugging on Huawei mobile phones 

1. Turn on the developer option USB debugging of the mobile phone. .

Open the search box of the settings, enter "developer", and the developer options will be displayed

Open "Developer Options" >

Check: USB debugging, allow ADB debugging         in "charge only" mode , monitor ADB installed applications. If it doesn't work, you can "Revoke USB Debugging Authorization" and try again.

        Speculation on the reason: It may be blocked due to security issues caused by unchecking "Monitor ADB installed applications" ( refer to the link ).

2. Use the data cable to connect the mobile phone and the computer.

After the mobile phone is connected to the computer, choose to transfer files in the prompt, open Huawei Mobile Assistant, and enter the secret key to connect to the mobile phone after the computer is installed. This step may be omitted, anyway, this is how I do it.

3. Find the adb debugging tool under Unity, as shown below:

 The path can be used as a reference, subject to your actual installation path! If you don’t want to find it, you can use this tool to find it, Everything https://everything.en.softonic.com/

4. Open adb 

For Win11, just right-click the path and select "Open in Terminal".

For other systems, you can directly use the cmd command to open, Win+R to open the run command window, enter cmd and press Enter, copy the adb path folder

 Enter the command (cd path) to open this folder

cd C:\Program Files\Unity\Hub\Editor\2021.3.4f1c1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\platform-tools

Enter dir to list all the files under the folder, the display is roughly as follows:

 Enter adb to display the version number and help information

5. ADB test

# 用USB数据线连接电脑,查看连接上的设备,这里应该有1个设备
adb devices

#切换计算机的adb为wifi连接模式
adb tcpip 5555

#连接手机的ip地址,如果连接成功,则可拔掉数据线
adb connect 192.168.0.6:5555

#查看连接上的设备,这里应该有2个设备,一个是手机的IP地址
adb devices

 My place is now connected to WiFi, and the USB is disconnected. The test is as follows

 In this way, open a large list in front of adb. It looks annoying. You can configure the environment variables and open cmd directly to use it!

Environment variable configuration can refer to here https://blog.csdn.net/hack_yin/article/details/125158644?spm=1001.2014.3001.5502

My computer has multiple adb, and I have specially configured environment variables before.

adb的常用命令

adb 查看adb的相关信息,包括版本号,常用命令
adb help 查看adb的相关信息,包括版本号,常用命令
adb version 查看adb版本
adb forward --list  列出所有的socket连接
adb logcat  显示设备日志
adb install PackageName.apk 安装apk
adb install -r abc.apk 覆盖安装
adb uninstall com.wangyin.wy 卸载APP
adb uninstall -k com.wangyin.wy 保留数据卸载APP
adb devices 查看连接主机的设备,
adb logcat 捕获设备的日志信息
adb logcat -s Unity 专门获得Unity相关的日志(注意U要大写)
adb push 文件名 手机端SDCard路径 例如:adb push xxx.jpg /sdcard/
adb pull /sdcard/xxx.txt 从手机下载文件
adb shell pm list packages 查看手机端安装的所有APP包名
adb shell screencap /sdcard/screen.png 截图
adb shell screenrecord /sdcard/demo.mp4 录制视频

 Two, Android Logcat debugging display log

 Open the Unity side (Windows->Package Manager)

Search for Android Logcat, install

 Open Android Logcat (window->analysis->Android Logcat or use the shortcut key alt+6 to open)

 Click  <Enter IP> / Other connection options    to enter the IP address and port of the mobile phone to connect to the mobile phone.

Guess you like

Origin blog.csdn.net/hack_yin/article/details/125205274