Unity2022.2 version Android packaging environment stepping on the pit

Recently, the project used Unity 2022.2 version, and encountered some problems when packaging Android: the Android JDK, SDK, and NDK downloaded from UnityHub are not supported in the unity editor. The reason is that the jdk version downloaded by the hub is the old version 8.0. This version of unity requires OpenJDK version 11 and NDK r23b, refer to the official website: Android Environment Settings - Unity Manual (unity3d.com)

So here the hub download is not available, we need to manually download the relevant JDK and SDK, the operation steps are given below:

1. Use UnityHub to download "Android Build Support", click the drop-down button, check "Android SDK & NDK Tools" and " OpenJDK ", and then install it in the next step.

 2. Download the corresponding version of JDK, official website link  https://jdk.java.net/archive/  or  Java Downloads | Oracle

Both are fine, but if it is version 11, there are many related tutorials, Baidu by yourself; Install JDK.

3. Download the corresponding version of NDK, note that higher versions are not acceptable, only the corresponding version is available;

Win: https://dl.google.com/android/repository/android-ndk-r23b-windows.zip
Mac: https://dl.google.com/android/repository/android-ndk-r23b-darwin.dmg

4. Install or decompress JDK and NDK, remember the corresponding path, JDK remember to configure system environment variables;

5. Unity opens the Android project and modifies the path of JDK and NDK:

Edit->preference ->External Tools 

 Do not change the path of the SDK. If you download the SDK directly from the Internet and install it, it will not be installed. It will prompt that the current SDK requires JDK version 1.5 or higher. At this time, we need to take some actions;

4. Download the cmdline tool  https://developer.android.com/studio#command-tools and unzip it. In the directory where you installed the Android module on your UnityHub, the location is:

(unity installation directory)\2022.2.2f1c1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK, then create a folder named cmdline-tools here, and then create a folder named latest in cmdline-tools, and download the tool Copy the content in the directory cmdline-tools to the created latest folder (note: not copy the upper folder, but copy the contents inside)

5. Use unity to package your Android project, a prompt box will pop up, select the "Update Android SDk" option, after the update is complete, go to the created cmdline-tools folder, and you will find an additional folder named 6.0. Delete the latest folder created originally, and change the 6.0 file name to latest​​.

6. Now repackage the Android project. ​​​​​​

Guess you like

Origin blog.csdn.net/weixin_45420056/article/details/128821621