Caused by java lang classnotfoundexception javax xml bind annotation xmlschema

How To Fix Java.Lang.NoClassDefFoundError: Javax/xml/bind/annotation/xmlschema When Install Android SDK

When I install android SDK use android SDK manager, it throws an error exception in thread “main” java.lang.noclassdeffounderror: javax/xml/bind/annotation/xmlschema . It cost me a lot of time to investigate. Now I will tell you how to fix it in detail.

$ ./sdkmanager 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: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

1. Downgrade JDK Version To Fix Exception in thread “main” java.lang.NoClassDefFoundError:javax/xml/bind/annotation/XmlSchema Error.

The reason for this error is because the JDK version that is used is too new. So first you need to find out which Java version are you using.

    Open a terminal and run the command $ java -version like below.

$ java -version java version "12.0.1" 2019-04-16 Java(TM) SE Runtime Environment (build 12.0.1+12) Java HotSpot(TM) 64-Bit Server VM (build 12.0.1+12, mixed mode, sharing)

2. Edit JAVA_OPTS Environment Variable Value To Fix Exception in thread “main” java.lang.NoClassDefFoundError:javax/xml/bind/annotation/XmlSchema Error.

    For Windows, you can run the below command in a command console to set the system environment variable JAVA_OPTS. Please read the article How To Set Windows Environment Variables.

setx JAVA_OPTS=-XX:+IgnoreUnrecognizedVMOptions --add-modules java.se.ee /M or # If the above code does not take effect, then export the java.xml.bind like below code. setx JAVA_OPTS=-XX:+IgnoreUnrecognizedVMOptions --add-modules java.xml.bind /M
export JAVA_OPTS='-XX:+IgnoreUnrecognizedVMOptions --add-modules java.se.ee' or # If the above code does not take effect, then export the java.xml.bind like below code. export JAVA_OPTS='-XX:+IgnoreUnrecognizedVMOptions --add-modules java.xml.bind'

3. Google Released New Android SDK Command-line Tools For JVM 9, 10, 11, And Later.

  1. Google has released new Android SDK Command-line Tools for JVMs 9 and later versions. You can see this on the google issue tracker website.
  2. The new Android SDK Command-line Tools do not depend on JAXB EE modules which have been deprecated.
  3. You can download them in Android Studio to use them.
  4. You can also manually download them to your local machine from Google to use them.
  5. If you manually download them, you should unpack them to a subdirectory of the android_home directory ( set by environment variable $ANDROID_HOME ). For example, you can unpack the new Android SDK Command-line Tools to folder $ANDROID_HOME/command-line-tools.
  6. You can download the new Android SDK Command-line Tools follow these links. New Android SDK Tools Linux Version , New Android SDK Tools Windows Version, New Android SDK Tools macOS Version.
Читайте также:  main

Источник

APKAnalyzer Error

Caused by: java.lang.ClassNotFoundException: javax.xml.bind.annotation.XmlSchema

Recently, I was tasked with using Google provided tools to decompile an APK in a CI/CD pipeline. This is great, because Google provides a tool called APK Analyzer, and provide tools both within the IDE itself and options to run it via the Command Line. I can talk more about the actual task later. For now, I want to discuss the issue that I first ran into when attempting to run apkanalyzer from the terminal.

When I attempted to run apkanalyzer , I was immediately met with the following error:

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.tools.apk.analyzer.ApkAnalyzerCli.getAaptInvokerFromSdk(ApkAnalyzerCli.java:277) at com.android.tools.apk.analyzer.ApkAnalyzerCli.main(ApkAnalyzerCli.java:129) 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:522) . 5 more 

I did some quick searches and noticed some developers failed attempts at correcting this issue, so I figured I would create a post about it 🙂

If you’re like me (an Android Developer), you will probably get this error because your $JAVA_HOME is set to the built in JDK provided by Android Studio.

java --version java 14.0.1 2020-04-14 Java(TM) SE Runtime Environment (build 14.0.1+7) Java HotSpot(TM) 64-Bit Server VM (build 14.0.1+7, mixed mode, sharing) javac --version javac 14.0.1 echo $JAVA_HOME /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/ 

Well… oddly enough, that is not the version that is compatible to run apkanalyzer , so you need to set ths to a compatible version.

To see which versions of java you have installed on your machine (assuming you’re running a MAC), just use the following command.

/user/libexec/java_home -V 14.0.1 (x86_64) "Oracle Corporation" - "Java SE 14.0.1" /Library/Java/JavaVirtualMachines/jdk-14.0.1.jdk/Contents/Home 11.0.12.1 (x86_64) "Amazon.com Inc." - "Amazon Corretto 11" /Users/dustinsummers/Library/Java/JavaVirtualMachines/corretto-11.0.12/Contents/Home 1.8.0_312 (x86_64) "Amazon" - "Amazon Corretto 8" //Java/JavaVirtualMachines/corretto-1.8.0_312/Contents/Home 

With this command, you will see a number of locations for the different Java versions installed on your machine.

Читайте также:  How to create telegram bot with python

As you can see from earlier, I was running Java 14, but you will need to update to Java 18 (1.8) in order to use the apkanalyzer .

To do that as a one-time function, simply type the following:

export JAVA_HOME=//Java/JavaVirtualMachines/corretto-1.8.0_312/Contents/Home 

Now, if you re-run apkanlyzer , you will see the following:

apkananlyzer Subject must be one of: apk, files, manifest, dex, resources apk summary Prints the application Id, version code and version name. apk file-size Prints the file size of the APK. apk download-size Prints an estimate of the download size of the APK. apk features Prints features used by the APK. apk compare Compares the sizes of two APKs. files list Lists all files in the zip. files cat Prints the given file contents to stdout manifest print Prints the manifest in XML format manifest application-id Prints the application id. manifest version-name Prints the version name. manifest version-code Prints the version code. manifest min-sdk Prints the minimum sdk. manifest target-sdk Prints the target sdk manifest permissions Prints a list of used permissions manifest debuggable Prints if the app is debuggable dex list Prints a list of dex files in the APK dex references Prints number of references in dex files dex packages Prints the class tree from DEX. P,C,M,F: indicates packages, classes methods, fields x,k,r,d: indicates removed, kept, referenced and defined nodes dex code Prints the bytecode of a class or method in smali format resources packages Prints a list of packages in resources table resources configs Prints a list of configurations for a type resources value Prints the given resource's value resources names Prints a list of resource names for a type resources xml Prints the human readable form of a binary XML Usage: apkanalyzer [global options]  [options] [] Option Description ------ ----------- --human-readable Print sizes in human readable format 

If you want to set this permanently, you will need to update your $JAVA_HOME variable in your bash_profile or, if you’re a fish user like me, inside of your config.fish file.

Читайте также:  Удаление дубликатов в питон

Источник

Saved searches

Use saved searches to filter your results more quickly

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

macOS: Exception in thread «main» java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema #4932

macOS: Exception in thread «main» java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema #4932

Comments

Environment
Provide version numbers for the following components (information can be retrieved by running tns info in your project folder or by inspecting the package.json of the project):

  • CLI: 6.0.2
  • Cross-platform modules: 6.0.3
  • Android Runtime: 6.0.0
  • iOS Runtime: 6.0.1
  • Plugin(s):
  • OS: macOS 10.14.6
  • Shell: zsh

Describe the bug
When running tns setup (or better tns build android and the being redirected to env setup) I get 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.(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: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 

To Reproduce
Try setting up Nativescript local build env on macOS.

Additional context
Same as #1813, solved with @ssimpo solution. I’ve seen the issue has been closed as being hijacked, but it still exists.

The text was updated successfully, but these errors were encountered:

Источник

Оцените статью