Development of mobile applications in the Unity environment requires constant maintenance of tools, especially Android SDK. Over time, older versions of packages no longer meet Google Play requirements or contain vulnerabilities, forcing developers to update. However, this process is often fraught with path errors, JDK version conflicts, and complex environment variable settings. In this guide, we will look in detail at how to properly update without disrupting the functionality of existing projects.

It is critical to understand that updating the Android SDK is not just a click of a button, but a complex procedure that affects the settings of the Unity engine itself, operating system environment variables and Gradle configuration. Incorrect actions can lead to the project no longer being built and emulators refusing to start. We will look at both automatic methods through Unity Hub, and manual configuration via the command line for advanced users.

Preparing the environment and checking the current ones versions

Before starting any manipulations, it is necessary to conduct a complete diagnosis of the current state of your workspace. Problems often arise due to version desynchronization between Unity Editor, Android Build Support and the SDK itself. Open a console inside Unity or use your operating system's terminal to check the installed components. Make sure that you have administrator rights, as the process of writing to system folders may be blocked.

You should pay special attention to the version JDK (Java Development Kit)that is used by the project. New versions of the Android SDK often require more recent Java, while older projects may be tied to specific releases. Check the environment variable JAVA_HOME and make sure it points to the correct directory. If you are using the JDK built into Unity, make sure that it does not conflict with the system one.

๐Ÿ“Š What method of installing Unity are you using?
Unity Hub
Manual installation (.exe/.dmg)
Linux package manager
Other

For detailed information about the current SDK status, you can use the utility sdkmanager. Run it with the --listflag to see the packages available for update. This action will help identify outdated components, such as platform-tools or build-toolsthat require immediate attention. Ignoring this step may result in downloading unnecessary files or missing critical security patches.

Automatic updates via Unity Hub

The most secure and recommended method for most users is to use the built-in mechanisms Unity Hub. This method minimizes the risk of human error and automatically adjusts file paths. In the module installation window for a specific version of Unity, find the Android Build Supportsection. Here you will see additional options that need to be activated for full operation.

When selecting the Android module, make sure that the checkboxes opposite the items Android SDK & NDK Tools and OpenJDK. If these components are already installed, Unity Hub will prompt you to update them to versions compatible with the selected editor. After confirmation, the download and installation of packages will begin, which may take considerable time depending on the speed of your Internet connection. When the process is complete, you will need to restart the editor.

โ˜‘๏ธ Check before auto-updating

Done: 0 / 4

In some cases, the automatic installer may fail due to problems with folder permissions C:\app Files\Unity or similar on macOS. If you encounter this situation, try running Unity Hub as an administrator. It's also worth checking to see if your firewall is blocking connections to Unity download servers. Please note that using outdated versions of the SDK may result in the build being rejected when published to Google Play Console.

Manually setting paths in Unity settings

If you prefer to manage SDK versions independently of Unity or are using a custom installation, you will need to manually set paths in the engine settings. Go to menu Edit โ†’ Preferences โ†’ External Tools (on macOS: Unity โ†’ Preferences โ†’ External Tools). This section contains the key section Androidwhere the locations of all the necessary components are written.

The field Android SDK should point to the root folder of your development toolset. Typically this is a path like C:\Users\Username\AppData\Local\Android\Sdk on Windows or /Users/Username/Library/Android/sdk on macOS. If the path is incorrect, the button Apply will be inactive, or you will receive an error when trying to build. Make sure that inside this folder there are subdirectories platforms, tools and platform-tools.

โš ๏ธ Attention: Never move the SDK folder after the paths have been registered in Unity, without subsequently updating the settings. This will lead to complete inoperability of the build module and will require re-configuration of all environment variables.

Also in this menu you need to check the field JDK. If you are using system Java, provide the path to it. If you are relying on the version shipped with Unity, make sure the switch is in the correct position. A mismatch between the JDK versions and the requirements of the project's Gradle scripts is one of the most common causes of compilation errors. To apply the changes, click the button Apply and wait for the settings to be validated by the engine.

Updating components via the command line

For advanced users and teams working in a CI/CD environment, the most flexible method is to use the utility sdkmanager. This tool allows you to update specific packages without affecting unnecessary components, and is ideal for automating processes. Open a terminal and navigate to the cmdline-tools or tools/bin directory inside your SDK folder.

To update all installed packages to the latest stable versions, use the following command:

sdkmanager --update

This command will check the Google repositories and download the necessary files. If you need to install a specific version of the platform, for example to target a specific version of Android, use a flag --install with the package name, for example "platforms;android-34". This approach gives you complete control over which libraries are present on your system.

What to do if sdkmanager shows a license error?

If you see errors related to License acceptance, run the sdkmanager --licenses command in the terminal. You will need to press 'y' several times to confirm that you agree to the terms of use for each component. Without this step, installation of new packages will be blocked.

After completing the update via the console, do not forget to return to Unity and click the button Apply in the settings of external tools so that the engine re-reads the folder structure. Sometimes cached data can prevent new versions from being detected correctly, so clearing the project's temporary files can be helpful. Using the command line also allows you to install components without a graphical interface, which saves system resources.

SDK component Description of purpose Update frequency
Platform Tools Set of debugging utilities (ADB, Fastboot) Regularly, when new Androids are released
Build Tools Compilers and linkers for building APK/AAB As new API versions are released
Platform (API Level) Libraries of a specific Android version When a new version is released OS
NDK Tools for working with native code (C/C++) Less rare, depends on project requirements

Resolving common errors and conflicts

The update process rarely goes absolutely smoothly, and developers often encounter specific errors. One of the most popular problems is Gradle message "SDK tools out of date" or errors indicating version mismatch. In such cases, the first thing you should do is check the file local.properties at the root of your project. Make sure the SDK path in this file is up to date and has no typos.

Another common problem is low disk space. Old versions of the SDK can take up gigabytes of space, and the system may throw a write error when trying to install new updates. It is recommended to periodically clean the SDK folder from outdated versions build-tools and unused system images. This can be done through the SDK Manager GUI or manually by deleting the corresponding folders.

๐Ÿ’ก

Before deleting older versions of build-tools, make sure that your project is not hard-coded to a specific version in the build.gradle file. If the version is fixed, removing the corresponding package will result in a compilation error.

If you see errors related to missing licenses, this is often resolved by re-running the accept licenses command discussed earlier. It is also worth checking anti-virus software, which may falsely block the execution of update scripts or modification of files in the app Files directory. By temporarily disabling protection, you can diagnose whether it is the cause of the failure.

โš ๏ธ Attention: SDK Manager interfaces and folder structure may change with the release of new versions of Android Studio and Command Line Tools. Always check Google's official documentation if standard paths don't work or if utilities throw unexpected errors.

Optimization and final sanity check

After successfully updating all components, you need to make sure that Unity interacts correctly with the new development environment. Create a simple test project or open an existing one and try building (File โ†’ Build Settings โ†’ Build). Monitor the output console: the absence of red errors and the successful creation of the APK file indicate that the settings are correct.

Pay attention to the settings Player Settings in the Other Settingssection. Here the parameter Target API Level must meet the requirements of Google Play (usually one of the latest available versions of Android). If, after updating the SDK, this option is broken or becomes unavailable, check whether the path to platforms is correctly defined in the settings of external tools. Sometimes you need to manually select the desired version from a drop-down list.

๐Ÿ’ก

Successful SDK update is confirmed only by the actual build of the project. The theoretical correctness of the paths does not guarantee the absence of compilation errors, so a test build is required.

For maximum performance, it is recommended to enable the proxy server in the Unity settings if you are in a region with an unstable connection to Google servers. It's also useful to set up Gradle dependency caching to make rebuilt builds faster. Regularly updating the SDK ensures not only compatibility with new devices, but also access to compiler optimizations that can reduce the size of the final application.

Do you need to remove old versions of Android SDK before installing new ones?

Deleting the entire SDK folder is not necessary and is not even recommended if you have other projects that depend on older versions. However, it is worth removing specific legacy packages (such as old build-tools) via sdkmanager with the --uninstall flag to free up space. Unity usually works well with several versions of tools at the same time.

Why does Unity not see the installed Android SDK?

Most often the problem lies in the wrong path in the Preferences โ†’ External Tools settings. Make sure you specify the root SDK folder and not a subdirectory. Also check if the Android Build Support components are installed in the Unity Hub itself, as without them the integration may not be complete.

How do I update the SDK if I am running on Linux or macOS?

The process is similar to Windows, but the paths are different. On macOS the SDK is usually located in ~/Library/Android/sdk, and on Linux in ~/Android/Sdk. The sdkmanager utility is launched via the terminal in a similar way. Make sure that your user has write rights to these directories.

What to do if ADB stops working after the update?

Try to restart the ADB server with the command adb kill-server, and then adb start-server. If this doesn't help, check to see if your firewall is blocking the connection and make sure USB debugging is enabled in your phone's developer options. Sometimes reinstalling drivers helps.

Does updating the SDK affect applications that have already been published?

Updating the SDK on the developer's computer itself does not affect applications already published in the store. However, to download new versions of the application (updates), Google Play may require the use of current versions of the Target API Level, which are available only in the latest SDK.