Unity2019 configuration JDK, SDK, NDK, Gradle

A small project using AR Foundation was developed with Unity, and the exported project needs to be tested on an Android phone. I encountered a problem with configuring the environment when exporting, and found a lot of ways to finally solve it. Take a note.

The unity version I am using is 2019.2.12f. When the completed project needs to be exported, the JDK, SDK, DNK, and Gradle paths need to be set in the preference settings. Let's write about the configuration methods separately.

1. JDK

Download link: Java Downloads | Oracle

Download the appropriate version according to your own computer, and the download path to the computer must be in English. After the download is complete, configure the following settings in Computer Properties - Advanced System Settings - Environment Variables:

New system variable

Variable name: JAVA_HOME
Variable value: D:\jdk (JDK installation path, here is your own installation path)

Create a new CLASSPATH  variable, the variable value is:
;.;%JAVA_HOME%\lib\tools.jar;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\bin;

Then find Path in the variable, click Edit, and select New on the edit page to enter %JAVA_HOME%\bin and %JAVA_HOME%\jre\bin

After the configuration is complete, press and hold windows+r, enter cmd, and enter java and java -version in the black page to check whether the environment configuration is successful

2. SDK

Download the Android studio software, and download the required environment in the SDK Tools of the software

Note that all download paths must be in English, and the selection of the SDK Platforms version is related to the Android API set when the Unity3D project is exported.

After the download is complete, set it in the environment variable like JDK

 

 输入:C:\Users\DELL\AppData\Local\Android\Sdk\platform-tools

和C:\Users\DELL\AppData\Local\Android\Sdk\tools

(Set according to your actual installation location)

After the setting is complete, enter cmd in windows+r, and enter adb version on the command line

Check whether the configuration has been successful for a long time 

 3. Gradle

Find the mainTemplate.gradle file in the unity installation directory , mine is in D:\unity\2019.2.12f1\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\GradleTemplates

Open this file with Notepad to see the version of the Gradle plugin adapted to unity

In all the files in this folder, add maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/'} after the sentence repositories {**ARTIFACTORYREPOSITORY** .

My display is 3.4.0, add the relationship between the plug-in version and the Gradle version

Download the corresponding gradle version according to the version control, I downloaded 5.1.1

Do not have Chinese in the download path

 

4. Configuration in Unity

In the preferences configuration, select the corresponding folders for JDK, SDK, and Gradle.

 

 Then it can be exported.

All my environment versions are compatible with the unity version, for reference only

 

Guess you like

Origin blog.csdn.net/y0205yang/article/details/130668951