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.
Use the Unity Hub to install Android Build Support and the required dependenciesIn the context of the Package Manager, a dependency is a specific package version (expressed in the form package_name@package_version
) that a project or another package requires in order to work. Projects and packages use the dependencies attribute in their manifests to define the set of packages they require. For projects, these are considered direct dependencies; for packages, these are indirect, or transitive, dependencies. More info
See in Glossary: Android SDK & NDK tools, and OpenJDK.
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 how to add the Android modules:
To enable USB debugging, you must enable Developer options on your device. To do this, see Android’s Configure developer options documentation.
Use a USB cable to connect your device to your computer. 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. For more information on connecting your Android device to the SDK, refer to the Run Your App section of the Android Developer documentation.
For information on how to set up your development environment for Chrome OS devices, and enable ADBAn Android Debug Bridge (ADB). You can use an ADB to deploy an Android package (APK) manually after building. More info
See in Glossary debugging, see Google’s documentation on Chrome OS Developer Environments.
Before you can deploy to your device you need to manually connect with ADB via the device’s IP address.
To begin you need the IP address. Open up the Settings app and choose Network in the sidebar. Next click on the active network interface.
If the interface is wireless then next choose the SSID that you are connected to. In the details you will see your IP address. Make a note of it.
If you are using a wired connection your IP address will be shown on the first details page.
Now we are ready to connect. For the sake of this example let’s say that the device’s IP is 192.168.0.100. In a shell or terminal run the following command
adb connect 192.168.0.100
If the connection was successful you will see a message such as connected to 192.168.0.65:5555
. And adb devices
should verify that the device is connected.
List of devices attached
192.168.0.65:5555 device
From now on you may run ADB commands to target the device just as you would over a USB connection.
Note: If your device or host machine goes to sleep or loses network connectivity you may need to reconnect.
You should 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 folders under /Unity/Hub/Editor/[EditorVersion]/Editor/Data/PlaybackEngines/AndroidPlayer/
.
If you have multiple versions of Unity with the same required dependencies (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:
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 your Unity project.
Open the Preferences window (Windows and Linux: Edit > Preferences; macOS: Unity > Preferences).
In the left navigation column, select External Tools.
Note: Unity works with the most recent version of the Android SDK available at the time of the Unity version release.
Each version of Unity requires a specific version of the Android NDK:
Unity version | NDK version |
---|---|
2018.4 LTS | r16b |
2019.4 LTS | r19 |
2020.3 LTS | r19 |
2021.1 | r21d |
See the System requirements page for a complete list of requirements.
Unity Hub installs the latest version of the Android SDK Target API required by Google Play.
If you need to use a more recent version, you can change the Target API from the Target API Level field in the Player Settings window (menu: Edit > Project Settings > Player, then select the Android platform). You can find the Target API Level option in the Other Settings > Identification section.
After you select an option other than the default, Unity prompts you to update the Android SDK API. You can choose to either:
If you select an older version of the Target API, the Unity Android SDK Updater won’t be able to perform the update and gives an error message.
In this case, to update the Android SDK Target API, you must use the Android sdkmanager from either Android Studio or the command line tool. Regardless of the method you choose, make sure to select the correct Android SDK folder for Unity in the Edit > Preferences > External Tools window.
Important: On Windows, if you installed the Unity Editor in the default folder (/Program Files/
), you must run the sdkmanager with elevated privilege (Run as Administrator) to perform the update.