Search Unity

[Guide] Android SDK tools installation (CLI)

Discussion in 'Android' started by SaeedPrez, Dec 15, 2018.

  1. SaeedPrez

    SaeedPrez

    Joined:
    May 10, 2017
    Posts:
    6
    Hello friends,

    Disclaimer: This guide is only tried on Windows 10, but it might even work on Mac and Linux.

    With the introduction of Unity Hub I've been struggling to get all the diferent versions of Unity to work with my Android SDK tools (which I have installed seperately). When building for Android I kept getting errors like:

    • SDK Platform Tools version 0.0.0 < 23.0.0.
    • SDK Build Tools version 0.0.0 < 28.0.3.
    • Required API level 26.

    Step by step guide

    1. Go to https://developer.android.com/studio/ and download Android SDK Tools. Close to the bottom of the page you'll find the section Command line tools only, there you'll find the link to a ZIP-file for Windows platform.
    2. After it's done downloading, unpack it somewhere on your hard drive. I have unpacked mine in C:\Program Files\Android
    3. Open Command Prompt and change folder to the tools\bin folder where you unpacked Android SDK-tools, i.e.
      cd "C:\Program Files\Android\tools\bin"
    4. To get a list of all available packages type
      sdkmanager.bat --list
    5. You need to install:
      1. SDK Build Tools
      2. SDK Platform Tools
      3. SDK Platform
    6. Install the latest SDK Build tools (see version in list), type i.e.
      sdkmanager.bat "build-tools;28.0.3"
    7. Install SDK Platform Tools, type
      sdkmanader.bat "platform-tools"
    8. Install SDK Platform for your target API (see version in list), type i.e.
      sdkmanager.bat "platforms;android-26"
    9. Just a note that you could also install all packages at once, type i.e.
      sdkmanager.bat "build-tools;28.0.3" "platform-tools" "platforms;android-26"
    10. In Unity, open External Tools in your Preferences (Menu: Edit > Preferences) and uncheck the Android SDK Tools Installed with Unity checkbox and type in the path to your Android SDK Tools folder, i.e. C:/Program Files/Android

    Useful links

    That's it! It should work to build now without errors.
     
  2. Akrab

    Akrab

    Joined:
    Oct 28, 2015
    Posts:
    1
    Thank you very much! Very much helped out!
     
  3. ruanramos

    ruanramos

    Joined:
    May 6, 2017
    Posts:
    4
    Helped me a lot, thank you for your time to share.
     
  4. linojon

    linojon

    Joined:
    Aug 25, 2014
    Posts:
    118
    fyi, Unity Hub now installs the android sdk's for you so you should not need to install them manually as you describe above. I installed Unity 2019.1.7f1 and thought I'd checked the Android Build Support checkbox. After downloading and trying to build my app I got these errors. Had to go back into Unity Hub, and the Add Modules menu for this version, check the Android Build Support, to actually install the sdk's this time. (Unity Hub 2.0.2)
     
    Noxi027 likes this.
  5. whitrise

    whitrise

    Joined:
    Dec 18, 2016
    Posts:
    6
    Hi,
    I installed Android modules from Unity Hub too. But seems like it's have an issue. Because Unity Hub says 800MB+ download size. PlaybackEngines folder is under the 800MB. Also NDK folder is empty. I think Unity Hub or 2019.1.7 have issue with Android modules.

    Sorry i f*cked up grammar...
     
  6. SisMoon

    SisMoon

    Joined:
    Jan 6, 2019
    Posts:
    4
    Thank you SaeedPrez.

    I installed the SDK and NDK with unity hub and the NDK was empty. Then I uninstalled unity and installed the Android studio first, SDK and NDK. Finally, I installed unity again and unchecked the NDK box to verify the path. I received an error message , unity wants an older version of the ndk r19. So now I will try to fix this with your tips using the command prompt.

    I did open a ticket and the unity help desk is aware of the issue and they are working on it.

    Thanks,
    SisMoon
     
    Last edited: Jun 29, 2019
  7. araz01

    araz01

    Joined:
    Aug 2, 2016
    Posts:
    53
    absolutely miserable...
     
  8. IEdge

    IEdge

    Joined:
    Mar 25, 2017
    Posts:
    51
    Useful guide to install Android SDK without Unity Hub.
    Thank you bro!
     
  9. GeorgeAdamon

    GeorgeAdamon

    Joined:
    May 31, 2017
    Posts:
    48
    Running
    sdkmanager.bat --list
    was giving me this error:

    Code (CSharp):
    1. Warning: Could not create settings
    2. java.lang.IllegalArgumentException
    3.     at com.android.sdklib.tool.sdkmanager.SdkManagerCliSettings.<init>(SdkManagerCliSettings.java:428)
    4.     at com.android.sdklib.tool.sdkmanager.SdkManagerCliSettings.createSettings(SdkManagerCliSettings.java:152)
    5.     at com.android.sdklib.tool.sdkmanager.SdkManagerCliSettings.createSettings(SdkManagerCliSettings.java:134)
    6.     at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:57)
    7.     at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:48)
    I had to follow exactly these steps to get the command line tools to work:
    https://stackoverflow.com/a/60454207
     
    Last edited: May 6, 2020
  10. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,918
    There shouldn't be whitespaces beween
    -- and list
     
  11. GeorgeAdamon

    GeorgeAdamon

    Joined:
    May 31, 2017
    Posts:
    48
    Yes, of course, this was just a typo on my comment :)
     
  12. himanshuaneja99

    himanshuaneja99

    Joined:
    May 20, 2020
    Posts:
    2

    Hey, I'm currently using a Mac. When I use sdkmanger.bat --list command it shows the error "-bash: sdkmanager.bat: command not found". Can anyone please help me?
     
  13. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,918
    .bat file is a Windows file. For mac it would probably be something like

    Code (CSharp):
    1. sudo ./sdkmanager --list
     
  14. joepeijkemans

    joepeijkemans

    Joined:
    Apr 24, 2018
    Posts:
    6
    Hi there, I'm running the same version of Unity, but I cannot build for Android platform level 29, the dropdown menu only goes to 28. However, the playstore requires a minimum of 29. I installed via Unity hub. Do you know how I can fix this?
     
    RoyBannon likes this.
  15. ahmedaniss

    ahmedaniss

    Joined:
    Sep 18, 2019
    Posts:
    98
    problem fixed here :
     
  16. abdman0095

    abdman0095

    Joined:
    Jan 29, 2021
    Posts:
    1
    it didn't for me :(
    even I had chosen all platforms, android sdk openjdk files and else
     
  17. unity3dgamedevx

    unity3dgamedevx

    Joined:
    Jul 26, 2021
    Posts:
    3
  18. unity_23ahmedmahmoud

    unity_23ahmedmahmoud

    Joined:
    Nov 24, 2018
    Posts:
    3
    thank you friend
     
  19. furaha2

    furaha2

    Joined:
    Jan 17, 2023
    Posts:
    1
    worked.thank you
     
  20. stevenchan_playstudios

    stevenchan_playstudios

    Joined:
    Mar 1, 2017
    Posts:
    39
    for Unity 2021.3.24f1, can't find package ndk through sdkmanager
    ./sdkmanager --install "ndk;21.3.6528147"