Unity real machine debugging and pitfalls encountered

        The Huawei mobile phone I use, the unity version is 2020.2.3f1c1, and then I debugged it by connecting it with a USB data cable. I will record the whole process here. It seems that there is a wifi connection method, so I won’t think about it for now.

        Plug the USB cable into the computer and mobile phone, select "Transfer Files" for the USB connection option on the mobile phone, find "Settings" -> "About Phone", click the version number multiple times to turn on the developer mode, then return to "Settings" and find "System and Updates", find "Developer Options", go in and turn on "Developer Options" and "USB Debugging".

        To switch Unity to the Android platform, check the necessary options.

        Then use the cd command to locate the platform-tools directory of the Android ADK. If the Android module installed by unityHub is used by default, the path is as follows:

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

        Windows+R opens cmd. The default is c drive. There is no need to switch the drive letter. Directly enter cd and the above path in cmd. Note that there is a space after cd. There is adb in this directory. You can use the adb command adb devices to check whether the phone is connected.

        If the adb command is not normal, read this article: Unity3D development technology Android apk debugging - short book 

    Then open the tcp connection and enter the following command: adb forward tcp:34999 localabstract:Unity-com.ygq.Archer. The number here depends on what is displayed in your unity profiler. Finally Unity-write your own package name after it.

        When two 34999s appear under the playMode in the profiler, the connection is successful and you can build and run for real-device debugging. RunDevice is changed to your own mobile device here.

 In order to select the mobile phone for debugging in VS, you need to do the following to add the Android sdk directory. Just copy the Copy Path.

        Every time you exit the program on your phone, you need to "attach the unity debugger" again.

  1. Then select your mobile phone in the profiler's PlayMode, and then click "Build and Run" to perform real-device debugging.
  2. In order to facilitate debugging, set breakpoints on the C# and Lua codes in the vs editor or idea editor from the beginning.

Encounter problems:

        --- > protobuf_net.dll cannot be encoded or decoded on the mobile phone

Solution: Just replace it with the source code of protobuf_net in the teacher's MMO_Client project.

        --- > The computer side can download resources from the local iis server, but not after packaging the Android apk.

Error: Autoconnected Player Curl error 7: Failed to connect to 192.168.31.196 port 8080: The reason is that the mobile phone and computer are not connected to the same wifi, and the firewall on the computer needs to be turned off. The key points must be confirmed before it will take effect.

     --->报错:Autoconnected Player DllNotFoundException: Unable to load DLL 'xlua': The specified module could not be found.

Reason: The corresponding dll file is lost. I looked at the Android directory of the project's Plugins and found no files.

Solution: Re-download xlua and replace the Plugins folder

        ---> 报错:Autoconnected Player Could not produce class with ID 64,65,81,143等

Reason: This is because when Unity cuts the engine code, it cuts out the class code with ID 64, etc. , resulting in the inability to find it when running. Settings about clipping code are in Build Settings->Player Settings->Player->Managed Stripping Level

Solution: Create a new file named link.xml in the Assets directory of the project , add the class library corresponding to the missing ID to the link.xml file, and repackage the problem will be solved.

The class name corresponding to the official document id: Unity - Manual: YAML Class ID Reference

  --->Error report: Autoconnected Player LuaException: xlua/util.lua:45: cannot set allowSceneActivation, no such field. If the functions and variables of the system class cannot be accessed like this, the system has cut the code. Others are still there. There are NavMeshAgent, NavMeshSurface, Animation, AnimationEvent, Application, etc.

Solution: Add the corresponding class in the link.xml file

Guess you like

Origin blog.csdn.net/qq_34256136/article/details/132911781