- Android environment setup
- 1. Install the Java Development Kit
- 2. Download the Android SDK
- 2a. Install the Android SDK using the command line tools
- 2b. Install the SDK using Android Studio
- 3. Enable USB debugging on your device
- 4. Configure the Android SDK path in Unity
- 5. Download and set up the Android NDK
- Android SDK/NDK setup
- 1. Download the Android SDK
- 2. Install the Android SDK
- 3. Enable USB debugging on your device
- 4. Connect your Android device to the SDK
- 5. Configure the Android SDK path in Unity
- 6. Download and set up the Android NDK
- Android environment setup
- 1. Install Android Build Support and the Android SDK & NDK tools
- 2. Enable USB debugging on your device
- Customizing the Android SDK & NDK Tools and OpenJDK installation
- Change the OpenJDK path
- Change the Android SDK Tools path
- Change the Android NDK path
Android environment setup
Whether you’re building an Android application in Unity or programming it from scratch, you must set up the Android Software Development Kit (SDK) before you can build and run any code on your Android device.
1. Install the Java Development Kit
Download and install the Java Development Kit (JDK). Unity requires the 64-bit version JDK 8 (1.8).
2. Download the Android SDK
You can install the Android SDK using command line tools or through Android Studio. Android Studio provides an easy to use GUI based tool, but installs additional software on your computer. Using the command line tools is a smaller download and does not install additional software, but it can be more challenging to use.
2a. Install the Android SDK using the command line tools
Install or unpack the Android SDK. After installing, open the Android SDK Manager and add: at least one Android SDK Platform, the Platform Tools, the Build Tools, and the USB drivers if you’re using Windows.
To install an Android platform SDK and the associated tools:
Unzip the tools folder to a location on your hard drive.
Open a command-prompt window.
Navigate to the bin folder in the location where you unzipped the tools folder: “install folder” > tools > bin
Use the sdkmanager command line tool to retrieve the list of packages that you can install. The installable packages include the Platform SDKs, Build Tools, Platform tools, and other tools.
Select a version of the Platform SDK to install. Platform SDKs take the following form in the list: platforms;android-xx. The xx indicates the SDK level. The larger the number, the newer the package. Typically, you can install the latest available version. But, there might be cases in which Google has released a new version of the SDK that causes errors when you build your Unity Project. In that case you must uninstall the SDK and install an earlier version. The general format of the command for package installation is sdkmanager
. You can install the corresponding Platform Tools and Build Tools at the same time.
Example: sdkmanager “platform-tools” “platforms;android–27” “build-tools;27.0.3”
If you are running on Windows, install the USB device drivers.
This installs the SDK in a directory named “platforms” in the directory in which you unzipped the tools folder. Example: c:\ \platforms
2b. Install the SDK using Android Studio
Install Android studio from the Android developer portal. The Android developer portal provides detailed installation instructions.
Note: Android Studio provides some ease of use benefits, but it is not fully tested for compatibility with Unity installs. If you encounter errors, Unity recommends using the command line method.
When installing the Android platform SDK and other tools, you can typically install the latest available version. There might be cases in which Google has released a new version of the SDK that causes errors when you build your Unity Project. In that case you must uninstall the SDK and install an earlier version.
Install the associated Platform and Build tools at the same time. If you are running on Windows, install the USB device drivers.
3. Enable USB debugging on your device
To enable USB debugging, you must enable Developer options on your device. To do this, find the build number in your device’s Settings menu. The location of the build number varies between devices. The stock Android setting can be found by navigating to Settings > About phone > Build number. For specific information on your device and Android version, refer to your hardware manufacturer.
Build number as displayed in Android 5.0 (Lollipop) on a Samsung Galaxy Note 3
Note: On Android versions prior to 4.2 (Jelly Bean), the Developer options aren’t hidden. Go to Settings > Developer options, then enable USB debugging.
After you navigate to the build number using the instructions above, tap on the build number seven times. A pop-up notification saying “You are now X steps away from being a developer” appears, with “X” being a number that counts down with every additional tap. On the seventh tap, Developer options are unlocked.
Connect your device to your computer using a USB cable. If you are developing on a Windows computer, you might need to install the a device specific USB driver. See the manufacture web site for your device for additional information.
The setup process differs for Windows and macOS, and is explained in detail on the Android developer website. For more information on connecting your Android device to the SDK, refer to the Running Your App section of the Android Developer documentation.
Go to Settings > Developer options, and check the USB debugging checkbox to enable debug mode when the device is connected to a computer via USB.
Developer options as displayed in Android 5.0 (Lollipop) — Samsung Galaxy Note 3
4. Configure the Android SDK path in Unity
The first time you create a Project for Android (or if Unity later fails to locate the SDK), Unity asks you to locate the folder in which you installed the Android SDK.
If you installed the SDK using the sdkmanager, you can find the folder in \platforms\.
If you installed the SDK when you installed Android Studio, you can find the location in the Android Studio SDK Manager. To open the SDK Manager from Android Studio, click Tools > Android > SDK Manager or click SDK Manager in the toolbar.
SDK Manager toolbar button
To change the location of the Android SDK, in the menu bar go to Unity > Preferences > External Tools.
5. Download and set up the Android NDK
If you are using the IL2CPP scripting backend for Android, you need the Android Native Development Kit (NDK). It contains the toolchains (such as compiler and linker) needed to build the necessary libraries, and finally produce the output package (APK). If you are not targeting the IL2CPP back end, you can skip this step.
Download Android NDK version r13b (64-bit) from the NDK Downloads web page. Extract the android-ndk folder to a directory on your computer and note the location.
The first time you build a Project for Android using IL2CPP, you are asked to locate the folder in which you installed the Android NDK. Select the root folder of your NDK installation. To change the location of the Android NDK, in the Unity Editor, navigate to the menu: Unity > Preferences to display the Unity Preferences dialog box. Here, click External Tools.
Did you find this page useful? Please give it a rating:
Источник
Android SDK/NDK setup
Whether you’re building an Android application in Unity or programming it from scratch, you need to set up the Android Software Development Kit (SDK) before you can build and run any code on your Android device.
1. Download the Android SDK
Download the Android SDK from the Android Studio and SDK Tools download page. You can either use an Android Studio and SDK bundle, or only download the SDK command line tools.
2. Install the Android SDK
Install or unpack the Android SDK. After installing, open the Android SDK Manager and add at least one Android SDK Platform, the Platform Tools, the Build Tools, and the USB drivers if you’re using Windows.
3. Enable USB debugging on your device
To enable USB debugging, you need to enable Developer options. To do this, find the build number in your device’s Settings menu. The location of the build number varies between devices. The stock Android setting can be found by navigating to Settings > About phone > Build number. For different devices and Android versions, refer to your hardware manufacturer.
Build number as displayed in Android 5.0 (Lollipop) on a Samsung Galaxy Note 3
Note: On operating systems older than Android 4.2 (Jelly Bean), the Developer options aren’t hidden. Go to Settings > Developer options, then enable USB debugging.
After you have navigated to the build number using the instructions above, tap on the build number seven times. A pop-up notification saying “You are now X steps away from being a developer” appears, with “X” being a number that counts down with every additional tap. On the seventh tap, Developer options are unlocked. Go to Settings > Developer options, and check the USB debugging checkbox to enable debug mode when the device is connected to a computer via USB.
Developer options as displayed in Android 5.0 (Lollipop) — Samsung Galaxy Note 3
4. Connect your Android device to the SDK
Connect your Android device to your computer using a USB cable. If you are developing on a Windows computer, you need to install the appropriate USB driver for your device.
For more information on connecting your Android device to the SDK, refer to the Running Your App section of the Android Developer documentation.
5. Configure the Android SDK path in Unity
The first time you make a Project for Android (or if Unity later fails to locate the SDK), you will be asked to locate the folder where you installed the Android SDK. Select the root folder of your SDK installation. If you wish to change the location of the Android SDK, in the menu bar go to Unity > Preferences > External Tools.
6. Download and set up the Android NDK
If you are using the IL2CPP scripting back end for Android, you need the Android Native Development Kit (NDK). It contains the toolchains (such as compiler and linker) needed to build the necessary libraries, and finally produce the output package (APK). If you are not targeting the IL2CPP back end, you can skip this step.
Download the Android NDK version required by Unity from the NDK Downloads web page, and then extract it to a directory. The first time you build a project for Android using IL2CPP, you will be asked to locate the folder where you installed the Android NDK. Select the root folder of your NDK installation. If you wish to change the location of the Android NDK, in the Unity Editor, navigate to menu: Unity > Preferences… to display the Unity Preferences dialog box. Here, click External Tools.
Источник
Android environment setup
To build and run for Android, you must install the Unity Android Build Support platform module. You also need to install the Android Software Development Kit (SDK) and the Native Development Kit (NDK) to build and run any code on your Android device. By default, Unity installs a Java Development Kit based on OpenJDK.
Note: Unity supports Android 4.4 “KitKat” and above. See AndroidSdkVersions for details.
1. Install Android Build Support and the Android SDK & NDK tools
Use the Unity Hub to install Android Build Support and the required dependencies: Android SDK & NDK tools, and OpenJDK.
Add Android modules
You can install Android Build Support, the Android SDK & NDK tools and OpenJDK when you install the Unity Editor, or add them at a later time.
For information on adding the Android modules:
Note: If you’re using Unity on macOS 10.15 (Catalina) and you don’t install Android tools through the Unity Hub, your operating system’s default security settings will prevent the Android NDK binaries being executed. You must either change these security settings, or download a signed Android NDK (r16b) from the Android developer website.
If you are using a 2018 version of Unity, see the Unity 2018.4 documentation for information on manually installing these dependencies.
2. Enable USB debugging on your device
To enable USB debugging, you must enable Developer options on your device. To do this, find the build number in your device’s Settings menu. The location of the build number varies between devices; for stock Android, it’s usually Settings > About phone > Build number. For specific information on your device and Android version, refer to your hardware manufacturer.
After you navigate to the build number using the instructions above, tap on the build number seven times. A pop-up notification saying “You are now X steps away from being a developer” appears, with “X” being a number that counts down with every additional tap. On the seventh tap, Developer options are unlocked.
Note: On Android versions prior to 4.2 (Jelly Bean), the Developer options are enabled by default.
Go to Settings > Developer options (or, if this does not work, on some devices the path is Settings > System > Developer options), and check the USB debugging checkbox. Android now enters debug mode when it is connected to a computer via USB.
Connect your device to your computer using a USB cable. If you are developing on a Windows computer, you might need to install a device-specific USB driver. See the manufacturer website for your device for additional information.
The setup process differs for Windows and macOS and is explained in detail on the Android developer website. For more information on connecting your Android device to the SDK, refer to the Run Your App section of the Android Developer documentation.
Customizing the Android SDK & NDK Tools and OpenJDK installation
Unity recommends that you use the Unity Hub to install Android SDK & NDK tools, to ensure that you receive the correct versions and configuration. Unity installs Android SDK & NDK Tools and OpenJDK respectively in the SDK, NDK and OpenJDK folders under /Unity/Hub/Editor/[EditorVersion]/Editor/Data/PlaybackEngines/AndroidPlayer/.
If you have multiple versions of Unity with the same required dependencies (be sure to check System requirements for the latest) and you want to avoid duplicating the installation of Android SDK & NDK Tools and OpenJDK, you can specify a shared location in the Unity Preferences window. To do this, go to Preferences > External tools and enter the directory paths in the SDK and NDK fields:
Preferences window showing external tools settings for Android
Warning: Unity does not officially support versions of the OpenJDK, SDK, or NDK other than the ones it supplies.
To change the OpenJDK, SDK Tools, or NDK that Unity uses to build Android apps:
- Open the Project.
- Open the Preferences window (Windows and Linux: Edit >Preferences; macOS: Unity >Preferences).
- In the left navigation column, select External Tools.
Change the OpenJDK path
- Uncheck JDK Installed with Unity (recommended).
- In the JDK field, enter the path to the JDK installation folder, or use the Browse button to locate it.
Change the Android SDK Tools path
- Uncheck Android SDK Tools Installed with Unity (recommended).
- In the SDK field, enter the path to the SDK installation folder, or use the Browse button to locate it.
Unity works with the most recent version of the Android SDK available at the time of the Unity version release.
Change the Android NDK path
- Uncheck Android NDK Installed with Unity (recommended).
- In the NDK field, enter the path to the NDK installation folder, or use the Browse button to locate it.
Each version of Unity requires a specific version of the Android NDK to be installed:
Unity version | NDK version |
---|---|
2017.4 LTS | r13d |
2018.4 LTS | r16b |
2019.1 | r16b |
2019.2 | r16b |
2019.3 | r19 |
See the System requirements page for a complete list of requirements.
Источник