Failed to install android-sdk: "java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema"
I had a similar problem this morning (trying to build for Android using Unity3D). I ended up uninstalling JDK9 and installing Java SE Development Kit 8u144. Hope this helps.
brew cask uninstall java
# uninstall java9brew tap homebrew/cask-versions
brew cask install java8
# install java8touch ~/.android/repositories.cfg
# without this file, error will occur on next stepbrew cask install android-sdk
To solve this error, you can downgrade your Java version.
Or exports the following option on your terminal:
Linux/MAC:
export JAVA_OPTS='-XX:+IgnoreUnrecognizedVMOptions --add-modules java.se.ee'
Windows:
set JAVA_OPTS=-XX:+IgnoreUnrecognizedVMOptions --add-modules java.se.ee
If this does not work try to exports the java.xml.bind
instead.
Linux:
export JAVA_OPTS='-XX:+IgnoreUnrecognizedVMOptions --add-modules java.xml.bind'
Windows:
set JAVA_OPTS=-XX:+IgnoreUnrecognizedVMOptions --add-modules java.xml.bind'
And to save it permanently you can exports the JAVA_OPTS
in your profile file on Linux (.zshrc
, .bashrc
and etc.) or add it as an environment variable permanently on Windows.
ps. This doesn't work for Java 11/11+, which doesn't have Java EE modules. For this option is a good idea, downgrade your Java version or wait for a Flutter update.
Ref: JDK 11: End of the road for Java EE modules
set JAVA_OPTS=-XX:+IgnoreUnrecognizedVMOptions --add-modules java.se.ee
This fixed the problem on Windows for me.
Source 1, source 2