I’ve started fiddling in the world of mobile apps. Quite late you can say, but better late than ever! I’ve never had the need of it, as nowadays you really need a good idea to develop an app, otherwise there are already plenty of them. So I decided to try Nativescript with Vue.js (as I really like to study Vue more, too). Unfortunately when running tns setup
I was stuck in the following error:
Step 4 of 12:
Allow the script to install Android SDK?
Note that if you type all you won't be prompted for subsequent installations
(Y)es/(N)o/(A)ll
y
Installing Android SDK
Warning: Cask 'android-sdk' is already installed.
To re-install android-sdk, run:
brew cask reinstall android-sdk
Set ANDROID_HOME=/usr/local/share/android-sdk
Set ANDROID_SDK_ROOT=/usr/local/share/android-sdk
Configuring your system for Android development... This might take some time, please, be patient.
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 more
I was getting mad, I tried everything I could find online but with no success. I wasn’t able to install the local environment to build for Android.
When I was ready to reinstall the whole OS and start from scratch I finally nailed the right search and got led to NS issue #1813. It doesn’t really look like the same error but I started reading and close to the bottom a lot of good feedback for @ssimpo‘s comment: basically he says JAVA env vars aren’t being passed to sudo
. I immediately follow his advice and add
Defaults env_keep += "ANDROID_HOME JAVA_HOME"
aaaand…. GO! The java exception has gone and the script was able to move over to installing the Android SDK.
I don’t know the root cause of the problem, as I don’t really enjoy java that much, but I’m happy I was able to finish setting up the environment! Now I can focus on trying to code an app.
Heading photo by Ryan Franco on Unsplash
My friend you saved my day !! Thank you for your post.