Search Unity

  1. Looking for a job or to hire someone for a project? Check out the re-opened job forums.
    Dismiss Notice
  2. Unity 2020 LTS & Unity 2021.1 have been released.
    Dismiss Notice
  3. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Android SDK 29 “unable to install additional SDK platform” issue & workaround

Discussion in 'Android' started by florianpenzkofer, Sep 3, 2020.

  1. florianpenzkofer

    florianpenzkofer

    Unity Technologies

    Joined:
    Sep 2, 2014
    Posts:
    335
    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 https://docs.unity3d.com/Manual/android-sdksetup.html, 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.

    Until then please use the workaround above.

    Sorry for the inconvenience!
     
    ihgyug, djweaver, Unity_AlexP and 3 others like this.
  2. xLeo

    xLeo

    Joined:
    Sep 21, 2010
    Posts:
    105
    On Windows, to update the Android version manually on your Unity, you can:
    1) Run CMD/Powershell as Administrator
    2) 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.
     
  3. djweaver

    djweaver

    Joined:
    Jul 4, 2020
    Posts:
    105
    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:
     
  4. JC-Cimetiere

    JC-Cimetiere

    Unity Technologies

    Joined:
    May 8, 2014
    Posts:
    124
    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.

    upload_2020-10-23_9-6-52.png
     
    xLeo likes this.
  5. waldgeist

    waldgeist

    Joined:
    May 6, 2017
    Posts:
    203
    > 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.
     
  6. JC-Cimetiere

    JC-Cimetiere

    Unity Technologies

    Joined:
    May 8, 2014
    Posts:
    124
    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.

    Hope this helps!
    JC
     
  7. Voxel-Busters

    Voxel-Busters

    Joined:
    Feb 25, 2015
    Posts:
    983
    Another alternative workflow we suggest for our plugin users is as below.
    1. Have the default android sdk installed path (For ex: installed through Android Studio). I call this DEFAULT_ANDROID_SDK
    2. Have the path of unity's android sdk path. I call this UNITY_ANDROID_SDK
    3. Go to DEFAULT_ANDROID_SDK
    4. Copy build-tools/29.x (or 30.x) and platforms/android-29 (or android-30)
    5. Paste it in corresponding folders in UNITY_ANDROID_SDK

    This way you don't need to change any paths in Unity. Hope it's helpful.
     
  8. hassan7451000

    hassan7451000

    Joined:
    Nov 20, 2017
    Posts:
    1
    I solved this by running Unity as an administrator.
     
  9. skdev3

    skdev3

    Joined:
    Jul 15, 2015
    Posts:
    57
    How To Use Update in Windows.
    1. Save this code to sdk.cmd.
    2. Modify UNITY_VERSION
    3. Add or change the SDK you need: platforms;android-XX
    4. Run sdk.cmd as Administrator.
    Code (CSharp):
    1. set UNITY_VERSION=2020.1.8f1
    2.  
    3. c:
    4. set JAVA_HOME=c:\Program Files\Unity\Hub\Editor\%UNITY_VERSION%\Editor\Data\PlaybackEngines\AndroidPlayer\OpenJDK\
    5. set ANDROID_HOME=c:\Program Files\Unity\Hub\Editor\%UNITY_VERSION%\Editor\Data\PlaybackEngines\AndroidPlayer\
    6. cd %ANDROID_HOME%SDK\tools\bin\
    7. echo.> %USERPROFILE%\.android\repositories.cfg
    8.  
    9. cmd /C sdkmanager --update
    10. cmd /C sdkmanager "platform-tools" "platforms;android-29"
    11. cmd /C sdkmanager "platform-tools" "platforms;android-30"
    12. cmd /C sdkmanager "platform-tools" "platforms;android-31"
    13.  
     
    marut88418 likes this.
unityunity