Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

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:
    445
    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:
    149
    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:
     
    bitsofbas, ErkanAkin, JA5PAR and 11 others like this.
  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:
    237
    > 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:
    1,381
    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:
    63
    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. Olli_wurghi

    Olli_wurghi

    Joined:
    Apr 11, 2013
    Posts:
    45
    thx @skdev3 this worked for me
     
    skdev3 likes this.
  11. -chris

    -chris

    Joined:
    Mar 1, 2012
    Posts:
    79
    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.
     
    kaskill, TigerHix, clamum and 2 others like this.
  12. fangye_Studio

    fangye_Studio

    Joined:
    Nov 19, 2012
    Posts:
    25
    Saved my life, thanks a lot ~
     
  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:
    19

    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:
    94
    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:
    94
    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:
    94
    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:
    42
    @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:
    63
    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:
    358
    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:
    358
    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:
    63
    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:
    358
    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:
    992
    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...
     
unityunity