Developing mobile games on the Android platform requires careful preparation of the working environment. Unity provides powerful tools for creating cross-platform projects, but without the correct connection Android SDK (Software Development Kit), the process of compiling and publishing the game will become impossible. Many developers encounter errors at the build stage precisely because of the lack or incorrect configuration of the necessary libraries and platform tools.
In this guide, we will look in detail at how to integrate the Android SDK into the Unity ecosystem. You will learn about two main installation methods: through the official module inside the editor itself and manually through Android Studio. Understanding these processes will help you avoid common mistakes related to file paths and versions. Build Tools.
The setup process can seem confusing due to the many versions and dependencies. However, following a clear algorithm of actions, you can prepare your development environment in a matter of minutes. apk or .aab.
Preparing to install modules
Before you start downloading heavy packages, you need to make sure that your Unity instance is ready to work with mobile platforms. A standard editor installation often only includes the basic PC modules, so Android support must be added separately via Unity Hub. This centralized application manages engine versions and installed components.
Open Unity Hub and go to the Installs. Find the version of the editor you plan to work with and click on the gear icon or three dots next to it. In the drop-down menu, select Add Modules. A list of available add-ons will open, among which you need to find Android Build Support.
When you select the main Android support module, the system will automatically offer to install child components. It is critical not to skip this step, as without them the SDK will not function properly. The list of required components includes:
- ๐ฆ Android Build Support โa basic package for compiling projects for the Android OS.
- ๐ค Android SDK & NDK Tools โa set of development tools and native libraries required for building.
- ๐ฑ OpenJDK โa Java runtime environment required for Gradle and build tools to work.
โ ๏ธ Attention: Make sure there is enough space on your disk free space. The full package of modules can take from 5 to 10 GB depending on the version of Unity and the selected archiving components.
After selecting all the necessary checkboxes, click the button Continue and wait for the download and installation to complete. This process may take some time depending on the speed of your Internet connection. Upon completion of installation, the modules will be automatically integrated into the project structure.
Automatic installation via Unity Hub
The most reliable and recommended way to obtain the Android SDK is to use the built-in Unity bootloader. This method ensures that the SDK, NDK, and JDK versions are fully compatible with the specific version of your editor. You don't have to manually search for the required releases or configure paths to executable files.
When you install modules via Unity Hub, the system automatically downloads the minimum required set of tools from Google. They are placed in a hidden folder inside the Unity installation directory. Typically the path looks like this: C:\app Files\Unity\Hub\Editor\[Version]\Editor\Data\PlaybackEngines\AndroidPlayer\SDK. Using this default path eliminates configuration errors.
To verify the installation is correct, open your project in Unity. Go to menu Edit โ Preferences (on macOS: Unity โ Preferences). In the window that opens, find the section External Tools. Here you will see a section Androidwhere the paths to SDK, NDK, JDK and Gradle should be specified.
If the fields are filled in automatically, it means the integration was successful. You can immediately proceed to setting up the project. However, if you see empty fields or warnings, you may need to specify the paths manually or reinstall the modules. Sometimes antivirus software can block files from being written to system folders, resulting in an incomplete installation.
If the automatic installation fails, try running Unity Hub as an administrator. This will give the necessary rights to write files to protected system directories.
Manual configuration via Android Studio
In some cases, developers require a more advanced version of the SDK or specific tools that are not included in the standard Unity package. Then it is advisable to install Android Studio the official development environment from Google. This approach gives full control over the versions of platforms and build tools.
Download the Android Studio installer from the official developer website. During the installation process, make sure that the installation option is checked Android SDK. After installation is complete, launch SDK Manager through the studio tools menu. Here you can download specific versions Android SDK Platform and SDK Build-Tools.
To work with Unity, it is critical to install the following components through the SDK manager:
- ๐ ๏ธ Android SDK Build-Tools โselect the version recommended for your version of Unity (usually one of the latest stable versions).
- ๐ฒ Android SDK Platform โinstall the platform that matches the target Android version of your application (API Level).
- ๐ฆ Android SDK Command-line Tools โrequired for some automation scripts to work.
After downloading all components, you need to manually link them with Unity. Go back to settings External Tools in the Unity editor. Uncheck Install Android SDK (if it is active) to disable the use of the built-in path. Then in the field Android SDK specify the path to the folder where Android Studio installed the tools (by default C:\Users\[Name]\AppData\Local\Android\Sdk).
โ ๏ธ Attention: When manually setting up, make sure that the system environment variables do not conflict with the paths specified in Unity. Having multiple versions of the JDK or The SDK can lead to unpredictable compilation errors.
Setting environment variables and paths
The correct operation of the build chain depends on how accurately Unity "sees" all the necessary tools. Even if the files are physically present on disk, an error in the path will make them inaccessible to the engine. settings JDK i Gradle.
In the External Tools section you can observe several key fields. The field JDK should point to the Java Development Kit installation folder. If you used the Unity Hub module, there will be a built-in version of OpenJDK. If you are using system Java, make sure it is version 11 or. 17, as older or newer versions may not be supported by the current release of Unity.
For advanced users, you may need to use your own version Gradle. In this case, uncheck Gradle Installed with Unity (recommended) and specify the path to your installation. However, for most tasks, the built-in Gradle is the best choice, since it is pre-configured for your needs. engine.
| Component | Description | Recommendation |
|---|---|---|
| Android SDK | Basic set of libraries and tools | Use the built-in one or the path from Android Studio |
| NDK | Native Development Kit for C++ code | Required for projects with native plugins |
| JDK | Java Development Kit | The version must meet Unity requirements |
| Gradle | Project build system | Use the built-in version for stability |
After changing any paths in the settings, be sure to restart the Unity editor. This ensures that all internal links are updated and cached data does not interfere with the new configuration. Ignoring this step often leads to errors like "SDK not found", even if the path is correct.
โ๏ธ Checking the External Tools configuration
Resolving common build errors
Even with the SDK installed correctly, developers may encounter errors during build project. One of the most common problems is a mismatch between the versions Build Tools and the target platform. If the project is set to API Level 33 and the SDK only has the tools version for API 30 installed, compilation will fail.
To resolve this issue, open Build Settings and check the field Target API Level. Make sure the appropriate platform is installed in your SDK through the manager. Also check the file gradleTemplate.properties or settings in Player Settingswhere dependency versions may be hardcoded that conflict with your system.
Another common error is related to paths containing Cyrillic characters or spaces. The Unity engine and Android SDK tools may not handle such paths correctly. Make sure that the path to the project, SDK and JDK contains only Latin letters and does not have spaces.
Error: FAILED: Build failed with an exception.* What went wrong:
Execution failed for task ':mergeDebugResources'.
> Error: The path must not contain spaces or non-ASCII characters.
If you see similar messages in the console, move the project to the root of the disk (for example, C:\UnityProjects\MyGame) and check the paths to the tools in the settings. Clean paths are key to the stable operation of the command line tools that Unity uses in the background.
What to do if the error persists after checking the paths?
Try deleting the Temp and Library folders in your project directory. Then restart Unity. This will force the engine to re-index assets and re-create temporary assembly files, which often eliminates phantom configuration errors.
Function check and first build
The final stage of configuration is a test build of the project. This action will confirm that all components are connected correctly and are ready to go. Create a simple scene, add any object to it, and go to the menu File โ Build Settings.
In the list of platforms, select Android and press the button Switch Platformif it is active. This process may take a few minutes as Unity recompiles the assets for the new architecture. After the switching is complete, make sure that the correct device or emulator is selected in the Android section.
Press the button Build or Build And Run. Select a folder to save the APK file. If the process is successful, you will see a build completion message in the console, and your application will launch on the connected device. If unsuccessful, carefully study the error log in the window Console.
โ ๏ธ Attention: The Unity and Android Studio interfaces are updated regularly. The location of some menu items or the names of settings may differ slightly in new versions. Always check the official documentation if the standard path does not work.
Successfully building a "Hello World" project means that your Android SDK is fully integrated. Now you can focus on developing the mechanics, graphics and logic of your game without worrying about problems with the build infrastructure.
Successfully building a test project is the only reliable way to confirm that all paths to the SDK, NDK and JDK are configured correctly and the system is ready for full development.
Where is the Android SDK folder when installed via Unity Hub?
By default, the SDK is installed in a hidden folder inside the Unity directory. The path usually looks like this: C:\app Files\Unity\Hub\Editor\[Version]\Editor\Data\PlaybackEngines\AndroidPlayer\SDK. The exact path can be seen in the Unity settings in the tab External Tools.
Do I need to install Android Studio if I have Unity?
No, this is not necessary. Unity Hub allows you to install all the required SDK, NDK and JDK components automatically. Android Studio is only required if you need specific versions of the tools or are doing deep native development.
Which version of Java (JDK) should you use for Unity?
It is recommended to use the version of the JDK that comes with Unity (OpenJDK), or version 11 or 17. Newer versions of Java (for example, 21) may be are incompatible with older versions of Gradle used in Unity.
What to do if Unity does not see the installed SDK?
Check whether the checkbox is unchecked Install Android SDK in the External Tools settings if you are using an external version. Make sure that the path is correct and does not contain Cyrillic. Restart the editor after changing the settings.