Issue:
When you select API Level 29 in Android Player Setting, Unity tries but fails to update the Android SDK:
The Android SDK that is currently installed with Unity Hub does not include support for API level 29. We are going to update the Hub install but we don’t not have yet determined when.
To update the Android SDK, Unity uses the Android sdkmanager command line tools, but the command will fail if it’s located in the filesystem in a path that has spaces (the default path used by the Hub on Windows e.g. “C:\Program Files\Unity\Hub\Editor\2020.1.2f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK”).
If you try to update the SDK with Android Studio SDK Manager UI tool with the SDK in such location, you will see a warning like this:
And the update will fail as well.
Workaround:
First we recommend you read the documentation about “Customizing the Android SDK & NDK Tools and OpenJDK installation” on this page Unity - Manual: Android environment setup, so you understand how & where Unity install the Android dependencies.
The simplest way to workaround this issue is to copy or move the Android SDK installed by the Hub to a different path that does not have spaces. After that you change the Android SDK path in the Unity Editor (Edit->Preferences->External Tools) and then let Unity update the SDK.
See screenshot below for example:
Future:
We are working on both updating Unity Hub installation process to include the latest Android SDK and fix the in Editor SDK update process. We will update this thread when these fixes are landing.
On Windows, to update the Android version manually on your Unity, you can:
Run CMD/Powershell as Administrator
Run this command: C:/{UNITY_EDITOR_PATH}/Editor/Data/PlaybackEngines/AndroidPlayer/SDK/tools/bin/sdkmanager.bat "platforms;android-29"
Another way that probably works (and I have yet to test it) is installing the Unity Editor on a path different than “Program Files”, something like C:\Unity. That way Unity won’t need to have Administrator permissions to update files and hopefully, Unity will properly handle and accept the terms that shows up when you try to update Android SDK.
What I and a few others have done is copy the android 29 sdk directly into the folder that unity looks in for sdks.
1) Make sure you have the android 29 SDK: Open Android Studio. After the splash screen has loaded, select the Configure button (bottom right, next to gear icon) and from the dropdown select SDK Manager and in the list make sure Android 10 (API 29) is checked, if it isn’t check it and apply to download the SDK.
2) Get the path to the Android SDK directory
From the same window, note the path in the text field labeled Android SDK Location
3) Get the path to Unity’s Android SDK directory
In Unity, click Edit => Preferences => External Tools. Scroll down and find a list of text fields with paths under the Android label. Note the path location in the field labeled Android SDK Tools Installed with Unity (recommended)
4) Copy the Android Studio SDK to Unity Navigate to both paths in explorer.In each there will be a folder called ‘platforms’. Go into this folder from the Android SDK path and copy the android-29 folder to the platforms folder in the Unity path.
Credit goes to this dude and the stack overflow post he credits that I can no longer find:
Update: With the Hub 2.4.2, the Android SDK installed with Unity Editor 2019.4LTS is now at API level 29.
The in-Editor update process for Android SDK still fails on Windows if the Editor is installed in the default “/Program Files/” folder, we are still working on fixing this.
The workaround described in the initial post is still valid, you can also change the Unity Editor install folder (attached screenshot), by selecting a path with no space in the name and where the current logged in user have full read/write permissions.
With the Hub 2.4.2, the Android SDK installed with Unity Editor 2019.4LTS is now at API level 29.
This was quite a surprise to me. And it’s pretty cumbersome to add another API level to the SDK, since you have to tweak Android Studio’s SDK folder to do this. I think it would be better if Unity included at least a couple of most common used and supported SDKs instead of breaking existing build processes. Or, there should be an easier way to add or remove SDKs. If there is, I’d be happy to learn about it.
Hi,
Unity Hub installs the latest version of the Android SDK Target API required by Google Play. We’re trying to stay in sync as much as possible. But if you need to use a more recent version, you can change the Target API in Player Settings, then Unity will ask if you want to update the Android SDK API.
(Note: We just fixed the issue where the SDK Update fails, and it will land in Unity 2020.2, 2020.1, 2019.4 in one of the next patch release, exact one still TBD)
If you select an older version of the Target API, the Unity Android SDK Updater will not be able to perform the update and will give you this message:
In this case, the easiest way to update the Android SDK Target API is to use the Android sdkmanager in Android Studio
In Android Studio SDK Manager tool, make sure you are selecting the right Android SDK folder used by Unity (found specified in Edit > Preferences > External Tools).
On Windows, if Unity Editor is installed in the default folder (/Program Files/), you will need to run the Android Studio with elevated privilege (Run as Administrator) to perform the update.
Running Unity Hub as Administrator allowed Unity to update to Android SDK 30 when prompted when performing a build – didn’t need to do any command-line stuff, nor copy any folders anywhere, and no Android Studio either.
hi , it seemed as it installed , and also the platform tools do exist in the correct folder.
so your script worked for me.
but i did another installation and it still makes the same error.
even when i open a new empty project, here is what i get after trying to build:
"
The specified Android SDK Build Tools version (28.0.3) is ignored, as it is below the minimum supported version (29.0.2) for Android Gradle Plugin 4.0.1.
Checking the license for package Android SDK Build-Tools 29.0.2 in C:\Program Files\Unity\Hub\Editor\2020.3.20f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\licenses
License for package Android SDK Build-Tools 29.0.2 accepted
"