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 --listIt 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.2As 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\
.
Now, try to build your project and voilà!
I did all the process but unity still says unable to detect android sdk
i need a full version of sdk with api level 9 to 29 for all versions of unitty
I see you don’t monetize markhlavac.com, don’t waste your traffic, you can earn additional bucks every month with new monetization method.
This is the best adsense alternative for any type of website (they
approve all websites), for more info simply search in gooogle: murgrabia’s tools
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
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! 🙂
I also faced this issue “unable to list target device”. I managed to solve it by following this website http://www.solutionfactory.in/posts/Setting-Up-Unity-for-Android-Device . Hope it helps someone
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!
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! =)
Can you still build for Android marshmallow using this?
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?
Remove all SDKs and try clean installation with only v25.
I solved this problem. you need to install Java SE Development Kit 8u144
http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
previously uninstall the old version.
Sorry for my english
I faced the same error and the problem for me was using “sdkmanager –list with two hyphens instead of “sdkmanager -list”
sorry i mean “sdkmanager –list”
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”
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”?
I just did. it looks like they’re there. Screenshot: https://www.dropbox.com/s/04vc1c6pk3ahi7a/SDKPackages.PNG?dl=0
I got it to build, but I think there is a problem with our app’s google analytics: https://www.dropbox.com/s/wg9fux6mhpmcauh/UnityError.PNG?dl=0
Anyway, thanks for the tutorial! I realize this is getting out of scope for you! 🙂
Thank you so much for the clear workaround!
Thank you so much for this guide. Fixed my problem immediately!
You are welcome 🙂
hi i cant find my path file figure me out please
hi suryan, which path file do you mean?