I have just installed Android Studio and imported a project. However, I am unable to build the project because I apparently have not proved my devotion to the Almighty Google accepted the relevant licenses.
> Failed to install the following Android SDK packages as some licences have not been accepted.
build-tools;28.0.3 Android SDK Build-Tools 28.0.3
platforms;android-28 Android SDK Platform 28
After some praying to the the all knowing google searches I found that a shell script sdkmanager
was installed in an unrelated location and must be run to accept the licenses. Having overcome the initial test of faith problem, I ran the script and encountered the following error.
Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema
at com.android.repository.api.SchemaModule$SchemaModuleVersion.<init>(SchemaModule.java:156)
at com.android.repository.api.SchemaModule.<init>(SchemaModule.java:75)
at com.android.sdklib.repository.AndroidSdkHandler.<clinit>(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:583)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
... 5 mor
I found a number of people with the same problem online.
The most popular solution, from this question, suggests finding a particular line in the sdkmanager
shell script and adding -XX:+IgnoreUnrecognizedVMOptions --add-modules java.se.ee
. This results in the following error.
Error occurred during initialization of boot layer
java.lang.module.FindException: Module java.se.ee not found
After more searches and reading other answers it appears that the above change does not work for more recent versions of Java. Another answer, here, suggests the following.
- Manually modify the
sdkmanager
script - Downgrade to an older version of Java compatible with the modificatiosn made in step 1
- Run the shell script and accept the licenses
- Upgrade back to the current version of Java
- Finally compile the project
This seems like a little bit of overkill just to be able to compile an Android app on my Mac, but I'm willing to try. However I am unable to download Java 8 from the provided link as it requires an oracle account and I am unable to create one...
Does anyone know of a less complicated way to set up and compile an Android Studio project for the first time on Mac with Java 11 in 2019?