Search Unity

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:
    479
    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!
     
    Tankzo, iriegusto, ihgyug and 5 others like this.
  2. xLeo

    xLeo

    Joined:
    Sep 21, 2010
    Posts:
    194
    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:
    123
    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:
    388
    > 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:
    123
    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
     
    StarDevinBS likes this.
  7. Voxel-Busters

    Voxel-Busters

    Joined:
    Feb 25, 2015
    Posts:
    1,963
    Another alternative workflow we suggest for our plugin users is as below.
    Summary
    Just copy to unity android sdk from Android Studio sdk folders!

    Steps
    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.
     
    Last edited: Sep 25, 2021
  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:
    64
    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.  
     
  10. OlliQueck

    OlliQueck

    Joined:
    Apr 11, 2013
    Posts:
    49
    thx @skdev3 this worked for me
     
    SassyPantsy and skdev3 like this.
  11. -chris

    -chris

    Joined:
    Mar 1, 2012
    Posts:
    99
    Thanks for this tip.

    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.
     
  12. fangye_Studio

    fangye_Studio

    Joined:
    Nov 19, 2012
    Posts:
    26
    Saved my life, thanks a lot ~
     
    harsh1412 likes this.
  13. yusufince79

    yusufince79

    Joined:
    Sep 5, 2021
    Posts:
    1
    unity extensions are not yet initialized so we cannot say if the c program compatible with platform android hatası veriyor anlayamadım
     
  14. ASGS_DumbFox

    ASGS_DumbFox

    Joined:
    Sep 23, 2017
    Posts:
    22

    THANK. YOU. BLESS!
     
  15. sohaib_qadri

    sohaib_qadri

    Joined:
    May 19, 2014
    Posts:
    8
    Awesome man, thanks for posting, worked perfectly.
     
  16. bellenmark

    bellenmark

    Joined:
    Oct 21, 2021
    Posts:
    3
    this is awesome. error fix in just a few second
     
  17. JA5PAR

    JA5PAR

    Joined:
    Jun 25, 2017
    Posts:
    1
    Thank you so much! This video was exactly what i needed for updating mine to API level 31
     
  18. mahibritto

    mahibritto

    Joined:
    Apr 16, 2019
    Posts:
    1
    Thank you for the video. It really works. Saved me lot of time.
     
  19. shacharoz

    shacharoz

    Joined:
    Jul 11, 2013
    Posts:
    98
    it seems that unity hub 3.0 has build tools and sdk vs 30 support.
    but it doesnt seem to work.
    what can we do?
     
  20. shacharoz

    shacharoz

    Joined:
    Jul 11, 2013
    Posts:
    98
    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
    "
     
    Last edited: Dec 19, 2021
  21. shacharoz

    shacharoz

    Joined:
    Jul 11, 2013
    Posts:
    98
    SOLVED.
    1. updated the hub version
    2. changed the location of the installations to be without spaces.
    3. installed unity version 2020.3.25 LTS
    4. loaded the project with that version. 2020.3.25 LTS

    build process works as normal.


    upload_2021-12-19_12-27-12.png
     
  22. Falondrian

    Falondrian

    Joined:
    Nov 1, 2017
    Posts:
    73
    @florianpenzkofer

    It's 2022 now and the issue still exists. Play store now demands API 30+, so every android developer has to go and waste at least 20 minutes (at least on first encounter) to fix the issue. Please up the priority.

    Edit: I just read that Hub 3 now includes API 30, but it doesn't look like the underlying issue of sdk updating through the Unity editor is fixed?
     
  23. skdev3

    skdev3

    Joined:
    Jul 15, 2015
    Posts:
    64
    New 2022 flow. How To Use Update in Windows.
    1. Save this code to sdk.cmd.
    2. Add or change the SDK you need: platforms;android-XX
    3. Run sdk.cmd as Administrator.

    Code (CSharp):
    1.  
    2. set work_dir="c:\Program Files\Unity\Hub\Editor"
    3. for /D %%B in (%work_dir%\*) do (
    4. c:
    5. set JAVA_HOME=%%B\Editor\Data\PlaybackEngines\AndroidPlayer\OpenJDK\
    6. set ANDROID_HOME=%%B\Editor\Data\PlaybackEngines\AndroidPlayer\
    7. cd %%B\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\tools\bin\
    8. echo.> %USERPROFILE%\.android\repositories.cfg
    9.  
    10. cmd /C sdkmanager --update
    11. cmd /C sdkmanager "platform-tools" "platforms;android-29"
    12. cmd /C sdkmanager "platform-tools" "platforms;android-30"
    13. cmd /C sdkmanager "platform-tools" "platforms;android-31"
    14. cmd /C sdkmanager "platform-tools" "platforms;android-32"
    15. )
    16. pause
    17.  
     
    LT23Live and Falondrian like this.
  24. giantkilleroverunity3d

    giantkilleroverunity3d

    Joined:
    Feb 28, 2014
    Posts:
    383
    I performed the sdk.cmd. It did things.
    I have min of api 29 to match Android v11.
    The apk launches and then crashes per the Andy logcat with
    2022/03/26 12:03:54.716 12512 12512 Error AndroidRuntime java.lang.RuntimeException: Unable to get provider androidx.core.content.FileProvider: java.lang.ClassNotFoundException: Didn't find class "androidx.core.content.FileProvider" on path: DexPathList[[zip file "/data/app/~~HrhIZf2R4Vo9fQBnL2ohdw==/com.PhyzxEngineering.RollerSpace-3WyAJkjzd-zMALDB8FUuDg==/base.apk"],nativeLibraryDirectories=[/data/app/~~HrhIZf2R4Vo9fQBnL2ohdw==/com.PhyzxEngineering.RollerSpace-3WyAJkjzd-zMALDB8FUuDg==/lib/arm64, /data/app/~~HrhIZf2R4Vo9fQBnL2ohdw==/com.PhyzxEngineering.RollerSpace-3WyAJkjzd-zMALDB8FUuDg==/base.apk!/lib/arm64-v8a, /system/lib64, /system_ext/lib64]]

    The layers are JDK then SDK then Gradle.
    The build worked and the apk copied but that is not the whole story.
    How does one go about finding the problem or what layer is starts or ends up in at?
    The previous situation worked before I upgraded the Hub and the Unity version.

    ...and the Unity Hub 3.1.1 removes the ability to modify installs like before?
    Where tf do these people get their system configuration ideas from?
    And if one runs the Hub as Admin what new workflow hooper does one have go through to modify the install or do I nuke the previous one to make a new one? And what will that cluster?
     
    Last edited: Mar 26, 2022
  25. giantkilleroverunity3d

    giantkilleroverunity3d

    Joined:
    Feb 28, 2014
    Posts:
    383
    Using IL2CPP an ArmV64
    On a whim I turned off Google Play protect on my phone.
    Build finished but might not be correct and still crashed.
     
  26. skdev3

    skdev3

    Joined:
    Jul 15, 2015
    Posts:
    64
    Update flow.
    How To Use Update in Windows.
    1. Save this code to sdk.cmd.
    2. Add or change the SDK you need: platforms;android-XX
    3. Run sdk.cmd as Administrator.
    P.S. Some libraries may require older versions of android SDK. Also, check the path, some paths may be different for different installations. Also check the path to Java, if Java is installed differently, you need to fix JAVA_HOME.

    Code (CSharp):
    1.  
    2.  
    3. set work_dir="c:\Program Files\Unity\Hub\Editor"
    4. for /D %%B in (%work_dir%\*) do (
    5. c:
    6. set JAVA_HOME=%%B\Editor\Data\PlaybackEngines\AndroidPlayer\OpenJDK\
    7. set ANDROID_HOME=%%B\Editor\Data\PlaybackEngines\AndroidPlayer\
    8. cd %%B\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\tools\bin\
    9. echo.> %USERPROFILE%\.android\repositories.cfg
    10.  
    11. cmd /C sdkmanager --update
    12. cmd /C sdkmanager "platform-tools" "platforms;android-27"
    13. cmd /C sdkmanager "platform-tools" "platforms;android-28"
    14. cmd /C sdkmanager "platform-tools" "platforms;android-29"
    15. cmd /C sdkmanager "platform-tools" "platforms;android-30"
    16. cmd /C sdkmanager "platform-tools" "platforms;android-31"
    17. cmd /C sdkmanager "platform-tools" "platforms;android-32"
    18. cmd /C sdkmanager "platform-tools" "platforms;android-33"
    19. )
    20.  
    21.  
     
  27. giantkilleroverunity3d

    giantkilleroverunity3d

    Joined:
    Feb 28, 2014
    Posts:
    383
    Thank you and yes this works. The fix enabled me to get an APK push to the device, Nord N200, Andy 11.
    The APK is built and pushed but when launched on the android a black screen is shown, a horizontal white line is produced(I assume it is the 'Made in Unity pitch') then the apk closes.
     
    skdev3 likes this.
  28. newguy123

    newguy123

    Joined:
    Aug 22, 2018
    Posts:
    1,248
    Well I dont understand any of this.
    I have Hub 3.2.0 beta 3 installed in default location
    Unity 2020.3.36f1 installed in default location

    Trying to build my project, it says it needs NDK 19 and the one it installed from hub doesnt work...
     
  29. shadd1234v

    shadd1234v

    Joined:
    Jul 21, 2022
    Posts:
    3
    Building Library\Bee\artifacts\Android\libunity\armeabi-v7a\UnityICallRegistration.o failed with output:
    In file included from <built-in>:419:
    <command line>(3,9): error: '__ANDROID_API__' macro redefined [-Werror,-Wmacro-redefined]
    #define __ANDROID_API__ 22
    ^
    <built-in>(410,9): note: previous definition is here
    #define __ANDROID_API__ __ANDROID_MIN_SDK_VERSION__
    ^
    1 error generated.
    UnityEngine.GUIUtility:processEvent (int,intptr,bool&)
     
  30. shadd1234v

    shadd1234v

    Joined:
    Jul 21, 2022
    Posts:
    3
    Building Library\Bee\artifacts\Android\19qtv\libil2cpp.so failed with output:
    clang++: error: invalid linker name in argument '-fuse-ld=bfd.exe'
    UnityEngine.GUIUtility:processEvent (int,intptr,bool&)



    BuildFailedException: Incremental Player build failed!
    UnityEditor.Modules.BeeBuildPostprocessor.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args) (at <44a70d1b13cf47e29810e30f45ffae08>:0)
    UnityEditor.Modules.DefaultBuildPostprocessor.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args, UnityEditor.BuildProperties& outProperties) (at <44a70d1b13cf47e29810e30f45ffae08>:0)
    UnityEditor.Android.AndroidBuildPostprocessor.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args, UnityEditor.BuildProperties& outProperties) (at <0bc7e9c04c1540528b26863a0cb726ae>:0)
    UnityEditor.PostprocessBuildPlayer.Postprocess (UnityEditor.BuildTargetGroup targetGroup, UnityEditor.BuildTarget target, System.Int32 subtarget, System.String installPath, System.String companyName, System.String productName, System.Int32 width, System.Int32 height, UnityEditor.BuildOptions options, UnityEditor.RuntimeClassRegistry usedClassRegistry, UnityEditor.Build.Reporting.BuildReport report) (at <44a70d1b13cf47e29810e30f45ffae08>:0)
    UnityEngine.GUIUtility:processEvent(Int32, IntPtr, Boolean&)


    UnityEditor.BuildPlayerWindow+BuildMethodException: 8 errors
    at UnityEditor.BuildPlayerWindow+DefaultBuildMethods.BuildPlayer (UnityEditor.BuildPlayerOptions options) [0x002da] in <44a70d1b13cf47e29810e30f45ffae08>:0
    at UnityEditor.BuildPlayerWindow.CallBuildMethods (System.Boolean askForBuildLocation, UnityEditor.BuildOptions defaultBuildOptions) [0x00080] in <44a70d1b13cf47e29810e30f45ffae08>:0
    UnityEngine.GUIUtility:processEvent (int,intptr,bool&)
     
  31. shadd1234v

    shadd1234v

    Joined:
    Jul 21, 2022
    Posts:
    3
    Unity 2021.3.6f1 I'm useing Unity 2021.3.6f1
    can you helpe me
     
  32. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,905
    Please attach Editor.log
     
  33. GZEEM

    GZEEM

    Joined:
    Jul 20, 2018
    Posts:
    1
    I used this solution to download API 31
     
  34. PNUMIA-Rob

    PNUMIA-Rob

    Joined:
    Jan 7, 2015
    Posts:
    33
    This did it for me, only, read "Unity" as "Unity Hub".
     
  35. unity_D3XhYz9RnquY3A

    unity_D3XhYz9RnquY3A

    Joined:
    Sep 11, 2020
    Posts:
    1
  36. Zapan15

    Zapan15

    Joined:
    Apr 11, 2011
    Posts:
    186
    Still not working with spaces in the directory name. Please fix this, or at least add/show a message which indicates the issue.
     
  37. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,905
    Are you using a custom SDK ? In latest Unity versions, there's no known problems with having whitespaces in directory names.
     
  38. Zapan15

    Zapan15

    Joined:
    Apr 11, 2011
    Posts:
    186
    We do not use a custom SDK. We just installed 2020.3.46f1 on windows 10 (german version, "C:\Program Files\Unity\Hub\Editor\2020.3.46f1...") and got the message above. After changing the location of the SDK to a folder without spaces ("D:\unityAndroidSDK") it worked.
     
  39. shamsad

    shamsad

    Joined:
    May 1, 2022
    Posts:
    2
    You are my man
     
  40. sebj

    sebj

    Joined:
    Dec 4, 2013
    Posts:
    70
    Heads up that there is a difference between the platform and build tools. If you have an issue like shacharoz you need to update the latter, which is a different command...

    Update 2021.3.3f1 and 29.0.2 as required...
     
  41. Ezzo24

    Ezzo24

    Joined:
    May 17, 2017
    Posts:
    7

    Where can i put this code ???

    should i use Command prompet or Visual studio n write a script on it and attache it with unity???

    please help
     
  42. silicongames

    silicongames

    Joined:
    Dec 3, 2020
    Posts:
    5
    open notepad and copy the commands in it, and as mentioned in step 1 save it as "sdk.cmd"
     
    Last edited: Sep 27, 2023
  43. kajloevesijn

    kajloevesijn

    Joined:
    Apr 27, 2021
    Posts:
    5
    don't forget to run as admin.