Introduction to mobile game development

Creating games for the platform Android has become one of the most popular areas in the entertainment industry, and the engine Unity occupies a leading position here due to its flexibility and cross-platform. However, before you can compile your first .apk file and run it on your smartphone, you need to correctly configure the development environment. The critical step is installing the Android SDK (Software Development Kit), which contains all the necessary compilation and debugging tools.

Many beginners encounter difficulties precisely at the stage of pairing Unity and Google tools, so as a process requires attention to software versions and file paths. Mistakes in configuration can cause the build button to be disabled or the process to fail with a fatal error. In this material, we will look in detail at how to avoid common problems and prepare your working environment.

You do not need to be an expert in system administration to cope with this task. It is enough to follow the step-by-step guide and understand the logic of interaction between the components. We will look at both automatic and manual installation methods so that you can choose the most suitable option for your operating system.

Preparing the working environment

Before starting installation, make sure that the latest version is installed on your computer Unity Hub and the Unity editor itself. It is important to understand that different versions of the engine may require specific versions of JDK (Java Development Kit) and NDK (Native Development Kit). You can check compatibility in the official documentation or in the settings window of your project.

The operating system also plays a role: although the process is similar on Windows and macOS, directory paths and access rights may differ. On Windows, there are often problems with long file paths, so it is recommended to install tools in the root of the disk or in folders with short names, for example C:\Android.

You must also make sure that you have administrator rights to install system components. Without these rights, installing USB drivers or writing environment variables may fail, blocking the ability to debug on the physical device.

  • ๐Ÿ“€ Check that you have free disk space (minimum 10 GB for SDK and cache).
  • โ˜• Ensure that the JAVA_HOME environment variable is set correctly.
  • ๐Ÿ”Œ Prepare a USB cable to connect the test device.
  • ๐Ÿ’พ Download the latest version of Unity Hub from the official website.

โš ๏ธ Attention: If you are using antivirus software, it may falsely block the installation of the emulator or ADB drivers. It is recommended to temporarily disable protection or add the installation folder to exceptions.

๐Ÿ’ก

Use an SSD drive to install the SDK and Unity projects. The speed of reading small files critically affects the time it takes to compile and import assets.

Installing Android Studio and Command Line Tools

Although Unity allows you to use built-in modules, the most reliable way to get all components is to install Android Studio. This is the official development environment from Google, which includes the SDK Manager. Even if you don't plan to write code in Java or Kotlin, this tool is essential for platform versioning.

During the installation process of Android Studio, you will be asked to select components. Be sure to check the boxes Android SDK, Android SDK Platform-tools and Android Emulator. Once the installation is complete, launch the SDK Manager to download the specific versions of the Android API that you plan to use in your project.

Integration with Unity often requires installation Command-line Tools. These utilities allow you to manage the SDK through the terminal, which is sometimes necessary to automate build processes (CI/CD). In the SDK Manager menu, go to the "SDK Tools" tab and find the desired item in the list.

Component Purpose Responsibility
Android SDK Platform API libraries for a specific Android version Required
SDK Build-Tools Tools for compiling application code Required
Android SDK Platform-Tools ADB and Fastboot utilities for debugging Required
Android Emulator Virtual device for testing Recommended
๐Ÿ“Š What version of Android are you targeting for your project?
Android 10 (API 29)
Android 11 (API 30)
Android 12 (API 31)
Android 13+ (API 33+)

Configuring modules inside Unity

After installing external software, you need to return to Unity Hub. When installing or changing the version of the Unity editor via Modules, make sure that component Android Build Supportis selected. Hidden within this component are two critical submodules: Android SDK & NDK Tools and OpenJDK.

If you prefer to use an external Android Studio installation rather than the built-in Unity one, you will need to specify the paths to them manually. This is often required when versions of tools in Unity are out of date or conflict with other projects on the computer. Go to the menu Edit โ†’ Preferences โ†’ External Tools.

In the section Android you will see fields for specifying paths. If the "Install Android Tools" checkbox was unchecked when installing Unity, the fields will be empty. Click the browse button and specify the path to the folder where you installed the Android SDK (usually this is C:\Users\Name\AppData\Local\Android\Sdk).

โ˜‘๏ธ Checking the External Tools setting

Done: 0 / 4

โš ๏ธ Attention: Never set paths to folders containing Cyrillic characters or spaces. This is a common cause of Gradle compilation errors that are difficult to diagnose.

How do I know which version of the NDK is needed? Unity clearly regulates this requirement. If you try to build without the required version, an error will appear in the console indicating the required version number. Download it via SDK Manager in Android Studio.

Resolving conflicts between JDK and Gradle versions

One โ€‹โ€‹of the most common problems is version incompatibility JDK. Unity 2019 and older versions often required JDK 8, while modern Unity 2021/2022 projects require JDK 11 or higher. Using the wrong version will result in an error during the Gradle initialization stage.

In the Unity settings (Preferences โ†’ External Tools), you can choose to use the built-in JDK (JDK Installed with Unity). This is the safest option for beginners as it guarantees compatibility. However, if you need specific features of the new version of Java, you will have to switch to an external installation.

The build system Gradle also requires attention. Recent versions of Unity use Gradle Daemon by default, which speeds up re-builds. If you encounter compilation freezes, try disabling this option or clearing the Gradle cache manually.

How to clear the Gradle cache?

To clear the cache, delete the .gradle folder in the user directory (C:\Users\UserName\.gradle) or use the gradle clean command in the project terminal. This will solve problems with corrupted dependencies.

Sometimes the error lies in the file gradle.properties. Make sure that the correct paths are entered there and that enough RAM is allocated for the build process, for example, the parameter org.gradle.jvmargs=-Xmx4096m.

Checking and debugging

After completing all the settings, you need to check whether Unity sees your device. Connect your smartphone via USB, enable USB debugging mode (USB Debugging) in the "For Developers" menu. In the Unity window, go to File โ†’ Build Settings and select the Android platform.

Press the button Run Device or look at the list of available devices. If your phone appears in the list, congratulations, the Unity-SDK combination works correctly. If the device is not found, check the installation of ADB drivers.

For diagnostics, use the Windows console or macOS Terminal. Enter the command adb devices. If in response you see the serial number of the device with status device, then the connection is established. Status unauthorized means that debugging needs to be confirmed on the phone screen.

โš ๏ธ Attention: Developer menu interfaces and item names may differ depending on the smartphone manufacturer (Samsung, Xiaomi, Pixel) and the Android shell version. Check the current instructions for your model.

๐Ÿ’ก

Successful display of the device in the Build Settings Unity list is the main indicator of the correct installation of all SDK components and drivers.

Try to build a simple test project. Click Build And Run. If the process went without errors and the application launched on the phone, the environment is completely ready for use. Now you can focus on gameplay development.

Frequently asked questions (FAQ)

Is it possible to install Android SDK without Android Studio?

Yes, it is possible. You can download Command Line Tools directly from the Android developers site and manage the packages through the terminal. However, for beginners, using Android Studio is preferable due to the presence of a graphical interface and automatic driver updates.

Why does Unity not see the installed JDK?

Most often the problem is in the environment variable JAVA_HOME. Make sure it points exactly to the JDK installation folder and not to (bin). Also check that the Java bitness (x64) matches the bitness of the installed Unity.

What is the minimum amount of RAM needed to build for Android?

For comfortable work, it is recommended to have at least 16 GB of RAM. With 8 GB, building is possible, but the process will be slow, and switching between the editor and the emulator can cause severe system slowdowns.

What to do if the error is "Gradle build failed"?

Try switching the Gradle version in the Player Settings from "Gradle Daemon" to "Legacy" or vice versa. Also clear the Temp and Library temporary folders in the project and restart Unity.