Unity USB connection Android real machine/simulator test

1. Download winSDK

First check whether the adb Android package has been installed in the computer: open the Windows PowerShell command window, enter the command adb version , if there is a version number, it means that there is no problem

Otherwise, you need to download the SDK , and then configure the environment variables

2. Quickly install the development game package

Prepare the development Android package and install it through the SDK: Find the location of your installation package, and execute the command adb install -r "relative path" in the PowerShell command window  , as follows

 Then wait for the installation to be successful, and a Success prompt will appear

2.1 Turn on the developer mode on the mobile phone

Settings → System → About Phone → Find the location of the version number and click continuously until the prompt to enable the developer mode appears, and then enable USB debugging after success

3. Run tools such as FrameDebug or Profiler in ADB mode to directly debug/test the mobile phone package

Open Unity (preferably empty project) and switch Android platform:

 

Then make sure the above settings are correct, execute the command adb forward tcp:34999 localabstract:Unity-add your package name in the PowerShell command window 

Note that the tcp port is 54999 in Unity before 2017, and 34999 after that. If you are not sure, you can also directly look at the second picture below

Then it’s OK, as long as you open the game on your mobile phone, click on the picture to debug Unity, and the Profiler is the same

4. ADB connection simulator

4.1 Simulator Settings

Check if there is a feature "Developer Options" in the "System Apps" settings

 If not, you need to enter the setting interface → about the tablet → click the version number 4 times in a row

After success, you will be prompted to enter the developer mode, enter the developer options, and turn on USB debugging

4.2 Profiler debugging

Execute instructions sequentially

  1. adb kill-server
  2. adb start-server
  3. adb connect 127.0.0.1:7555 (At this point, it is connected to the mumu simulator. It should be noted that the ports behind each simulator are different, and the port of the Yeshen simulator is (62001))
  4. adb devices (if the xxxx device information appears, it means that the device is obtained successfully)
  5. adb forward --remove-all (clear previous)
  6. Adb forward tcp:34999 localabstract:  Unity-add your package name (this step is consistent with the above)

After that, Unity opens the Profiler / FrameDebug window, as shown in the figure

After the connection is successful, it can be debugged like a mobile phone

Reference article:

  • https://www.jianshu.com/p/2c19e157d442
  • https://blog.csdn.net/weixin_45664217/article/details/120484794
  • https://docs.unity3d.com/cn/current/Manual/profiler-profiling-applications.html
  • https://www.jianshu.com/p/ab0139da5e39

Guess you like

Origin blog.csdn.net/Jaihk662/article/details/125542763