Problems with Unity exporting apk, JDK, Android SDK, NDK, no "installation module"

export apk failed

Use unity to export the apk file, and a prompt will appear: the appropriate version of JDK, Android SDK and Android NDK is required. It is very time-consuming to find, download and install the appropriate version.

Many tutorials on the Internet point out that modules can be installed directly in Unity Hub (as shown in the figure below):
insert image description here
(Source: https://www.bilibili.com/read/cv10235284 )

There is no option to "install modules"

But it will appear that there is no "install module" option in your own Unity Hub interface . At this time, you can click on the link below and click on the Unity Hub corresponding to your own version of unity: https://unity3d.com/get-unity/download/ archive

For example, my unity version is 2021.2.7f1c1, that is, the selection is as follows:
insert image description here
From this, the selection of "Install Module" will appear, and then select "Android Build Support" to install it.

reset path

After installing the "Android Build Support" module, a 2021.2.7f1 appeared on the Unity Hub on my computer based on the original 2021.2.7f1c1.
insert image description here
At this time, the apk package still fails because the path of JDK, SDK, and NDK is not set correctly in Unity→Edit→Preferences→External Tools. My default path is:

D:\Program Files\Unity 2021.2.7f1c1\Editor\Data\PlaybackEngines\AndroidPlayer\OpenJDK
D:\Program Files\Unity 2021.2.7f1c1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK
D:\Program Files\Unity 2021.2.7f1c1\Editor\Data\PlaybackEngines\AndroidPlayer\NDK

It needs to be replaced with the corresponding position under 2021.2.7f1

D:\Program Files\Unity 2021.2.7f1c1\2021.2.7f1\Editor\Data\PlaybackEngines\AndroidPlayer\OpenJDK
D:\Program Files\Unity 2021.2.7f1c1\2021.2.7f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK
D:\Program Files\Unity 2021.2.7f1c1\2021.2.7f1\Editor\Data\PlaybackEngines\AndroidPlayer\NDK

Gradle build failed

At this time, apk packaging is performed, and a new problem arises: Gradle build failed. See the Console for details.
Just remove the Chinese in the project path.
insert image description here

Reference blog: https://zhuanlan.zhihu.com/p/106132063

Guess you like

Origin blog.csdn.net/lj164567487/article/details/122489744