Installing Android SDK for Unity3D using SDK Tools and CLI

I don’t know why but last weeks I found myself several times in a situation that I had to create Android builds in the Unity3D on new computers or reinstalled ones. Each time I had to execute the whole process of setting up Android SDK and mess with some issues as the installation is not straightforward as it should be. This article is kind of cheatsheet for me but maybe someone else also appreciate it.

First issue is that you can install Android SDK either as a part of Android Studio bundle or using SDK Tools and CLI. Since I don’t like to download and install big softwares just for one scenario, I was glad to found out that there is really quick CLI option to install SDK without much overhead.

Second issue is related to Unity 5.6.2p1 (and earlier versions) failing to build Android SDK Tools 26.0, so for time being only version 25 is supported by Unity.

1. JDK Installation

Download and install Java Development Kit as you can’t do much anything without it. Current version is 1.8.0.

2. Android SDK 25 Tools Installation

In a normal situation we would download SDK Tools from Android Studio page. As we need older version 25 we can download it directly from the google repository.

After download extract the content to your SDK path. In our case we will use c:\Users\markey\AppData\Local\Android\SDK25\tools. Stop here for a while and take a notice that we created tools directory inside whole SDK directory. That is because tools are just one package of the whole SDK and other packages will be installed on the same level.

3. Installing packages using CLI and SDKManager

As a next step we are going to startup CLI and open our newly created tools directory:

cd c:\Users\markey\AppData\Local\Android\SDK25\tools\bin\
Now try to list all your installed packages using sdkmanager command:

sdkmanager --list
It should output something like that:

Installed packages:
Path | Version | Description | LocationU
------- | ------- | ------- | -------
tools | 25.2.5 | Android SDK Tools 25.2.5 | tools\

Available Packages:
Path | Version | Description
------- | ------- | -------
...
add-ons;addon-g..._apis-google-24 | 1 | Google APIs
...
build-tools;25.0.0 | 25.0.0 | Android SDK Build-Tools 25
build-tools;25.0.1 | 25.0.1 | Android SDK Build-Tools 25.0.1
build-tools;25.0.2 | 25.0.2 | Android SDK Build-Tools 25.0.2
build-tools;25.0.3 | 25.0.3 | Android SDK Build-Tools 25.0.3
build-tools;26.0.0 | 26.0.0 | Android SDK Build-Tools 26
...
platform-tools | 26.0.0 | Android SDK Platform-Tools
...
platforms;android-25 | 3 | Android SDK Platform 25
platforms;android-26 | 1 | Android SDK Platform 26
...
tools | 26.0.2 | Android SDK Tools

Available Updates:
ID | Installed | Available
------- | ------- | -------
tools | 25.2.5 | 26.0.2
As we can see tools are already installed, so we have to install three other packages platform-tools, platforms and build-tools. The CLI command for that is sdkmanager "package". If you like to explore sdkmanager more deeply then I recommend you to check out the documentation. For platforms and build-tools we have to specify proper version, so don’t forget to pick the one with version 25:

sdkmanager "platform-tools"
sdkmanager "platforms;android-25"
sdkmanager "build-tools;25.0.3"

4. Android paths setup in Unity

Go to the Unity and switch project to Android platform. Then open External Tools (see picture below) and set SDK path to
c:\Users\markey\AppData\Local\Android\SDK25\tools and also JDK path to where you installed it in the first step. In our case the path is
C:\Program Files\Java\jdk1.8.0_131\.

Setting Android SDK path in Unity3D

Now, try to build your project and voilà!

18 thoughts on “Installing Android SDK for Unity3D using SDK Tools and CLI”

  1. hello!
    i reinstalled android sdk for several times. but nothing changes.
    I think there is a problem that i know what’s exactly wrong. i don’t have any android folder in the path that you said:
    c:\Users\PC\AppData\Local
    do you know what’s the problem?
    unity version: 5.6.2 and 2018.1.0f2
    android API 27

  2. Thank you very much for the tips!

    Unity documentation do not comtemplate these steps on installing extra packages for Android SDK. You saved my life! 🙂

  3. I just want to say, thank you for making this tutorial. I’ve searched everywhere around the Internet about installing(reinstalling, in my case) and setting up the Android SDK and your tutorial was the only one that WORKED! I’ve spent countless hours banging my head on my desk about what I did wrong even though I did how I did it before(I have installed the Android SDK before. It doesn’t work now, for some reason) and your tutorial saved my time, and my sanity. Thank you so much!

  4. I spend about twelve hours and I couldn’t find a solution to lots of Android Build errors in Unity on my own. I’m very glad that I have found your post here!

    Thank you, Markey! It works! =)

  5. Hi!
    thanks for your useful tips, I when i perform the “sdkmanager –list” it shows this message:
    “Exception in thread “main” java.lang.UnsupportedClassVersionError: com/android/sdklib/tool/sdkmanagerCli : Unsupported major.minor version 52.0
    at java.lang.Classloader.defineClass1
    ….”
    and the list of “at java….” goes on for 15 lines!
    I have installed skd tools 24.4.1 and then downloaded and extracted the 25.2.3 tools in the pervious sdk tools and clicked over-right. (i think it’s ok because when i open my sdk manager and go to help>about it shows the current version is 25.2.3.
    so….. what u think is my problem?

    1. I faced the same error and the problem for me was using “sdkmanager –list with two hyphens instead of “sdkmanager -list”

  6. hmm, I was unable to build. the unity console mentioned these two other packages, which i tried to install but never appeared to complete…
    sdk manager “extras;android;m2repository”
    sdk manager “extras;google;m2repository”

    1. Hi David,
      not sure why is Unity asking for those packages, but did you check if they are correctly installed in “Installed packages” using command “sdkmanager –list”?

Leave a Reply

Your email address will not be published. Required fields are marked *