[Unity] Pitfalls - Debugging with Android real device on UnityPC

1. First of all, whether you use unity to directly create the apk or export the Android Project, and then use Android Studio to package it, when exporting the project on the unity side, you must check some options:

Supplement: It seems that you also need to turn on Player-Settings-Other Settings-Optimization-Enable Internal Profile:

 

2. After that, install the apk to the mobile phone, then open unity and connect the data cable to the mobile phone.

 

3. After that, you have to do the command line operation:

Here is a batch command:

Replace the mosaic part with the package name of your own apk (com.yourpackage.com)

Of course, the above operations must ensure that the adb environment is properly configured on the PC side.

Here is the code:

.\adb kill-server
.\adb forward tcp:34999 localabstract:Unity-com.yourpackage.com
@echo off
echo.&echo &pause>nul
@echo on
exit 

Afterwards, the command line will output the following results, indicating that the mobile phone is connected:

Sometimes you can't connect, please check the port number. (By the way, remember to turn on the USB debugging function on the mobile phone)

 

4. As expected, Profiler and Frame Debug have been connected to our mobile phone at this time:

 

5. Finally, if it is not connected, confirm that the USB debugging permission is turned on on the phone, then plug and unplug the data cable again, and repeat step 3.

Guess you like

Origin blog.csdn.net/qq302756113/article/details/115229971