Android SDK Manager from within Unity (?)

On macOS Unity 2019.2, I’m trying to figure out how to install additional SDKs for other Android versions. In Android Studio, it is easy. Just go to SDK Manager and install any needed SDKs for whatever version I’m targeting. With Unity now bundling the Android SDK and NDK now in v2019, I’m not sure where we’re able to launch SDK Manager to add any new SDKs.

I did find Android’s SDK Manager in /Applications/Unity/Hub/Editor/2019.2.8f1/PlaybackEngines/AndroidPlayer/SDK/tools/bin. However, when trying to launch it, it asks to download an Oracle JDK/JDM to run it.

Is there a way to launch the SDK Manager from within Unity directly?

The reason I’m trying to do this is because I’ve set my Minimum API Level to Android 7.0 in Build Settings and I’m unable to get the APK to install on my device. I suspect the new built-in SDK/NDK does not come with this API level.

There is no way to do that from the Unity editor. However you could use the SDK Manger from Android Studio by set the SDK path to “/Applications/Unity/Hub/Editor/2019.2.8f1/PlaybackEngines/AndroidPlayer/SDK/” in that manager.

If the reason for the failure would be the missing API level, then you would not be able to build your application and you would get an error while building. If you are not able to install the application on the device, then there probably is a different reason. What error do you get when the installation fails?

Thank you. This is great info on how to use AS to access Unity’s install of the sdk. I had never thought about doing it that way.

And, you are correct about the problem with not installing on the device as not being an API issue. I had an old version of the app on the device that needed to be removed before building the new one would install on the device properly.

Thank you again!

For anyone that finds this and is having problems with a Unity install not having an Android SDK when trying to build (I’m on 2020) here’s a potential fix I wish I would have found sooner:

windows:

  1. run CMD (command prompt) as an administrator: Right-Click “run as administrator
  2. navigate to the Android SDK Manager installed by Unity:

cd C:\Program Files\Unity\Hub\Editor\[UNITYVERSION]\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\tools\bin
3. I don’t know if you need to run the SDK here first or not, I did:

sdkmanager.bat
4. Run this code, adding the API version you want to install:

sdkmanager "platform-tools" "platforms;android-30"
5. Agree to terms: Y

Your missing SDK will now be installed, close and restart Unity if you had it open. You should now be able to do your build.

Hope that helps.

33 Likes

Thank you so much!

Tried that, got:
Exception in thread “main” java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema
at com.android.repository.api.SchemaModule$SchemaModuleVersion.(SchemaModule.java:156)
at com.android.repository.api.SchemaModule.(SchemaModule.java:75)
at com.android.sdklib.repository.AndroidSdkHandler.(AndroidSdkHandler.java:81)
at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:73)
at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:48)
Caused by: java.lang.ClassNotFoundException: javax.xml.bind.annotation.XmlSchema
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:602)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
… 5 more

And have no idea what that means :expressionless:

1 Like

You have a newer java version installed on your machine than java8. Take a look at this answer for potential solutions. https://stackoverflow.com/questions/46402772/failed-to-install-android-sdk-java-lang-noclassdeffounderror-javax-xml-bind-a/51644855#51644855

1 Like

In fact, the brief and summary of your question is described here https://www.gameplaydeveloper.com/unity-android-sdk/ So you may need to download the SDK plugins from scratch via the Unity Hub. I was also able to solve the problem by following this method.

It works for me. Thanks dude.

You saved a lot of time

Hi

I had a similar problem, searched all the forums, nothing helped.

In the end, I solved it by installing JDK 8, setting JAVA_HOME in Environment Variables, and the path to install JDK.
And also downloaded the latest Unity Hub 3.0.1 and installed Unity from it.

After that, everything worked.

Not sure what helped exactly, the latest Unity Hub or adding JAVA to Environment Variables…

H
i help me. I downloaded unity and installed it and wanted to download its internal stuff but it gives me an error

По какой-то причине я не могу загрузить инструменты командной строки Android SDK. Я получаю сообщение об ошибке

I had the same problem. Needed API level 32 for use with Meta Oculus Quest 3. Got it using the following command line in MACOS.

JAVA_HOME=/Applications/Unity/Hub/Editor/6000.1.6f1/PlaybackEngines/AndroidPlayer/OpenJDK ./cmdline-tools/16.0/bin/sdkmanager --install "platforms;android-32"