I am trying to run the apkanalyzer tool provided by Android SDK (under Sdk/tool/bin), but I am not able to make it work. I know that I can also use this tool through AndroidStudio, but I need to automate the apk analysis to cover a lot of APKs. So, I followed this https://developer.android.com/studio/command-line/apkanalyzer to use it.
Anyway, when I try to launch apkanalyzer (e.g. apkanalyzer apk summary APKname.apk) it gives the following exception:
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:583) at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:190) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:499) ... 5 more
Where is the problem?
I had the same issue. All I had to do was set the JAVA_HOME correctly. I set the JAVA_HOME in my bashrc to $PATH_TO_ANDROIDSTUDIO/jre
my exact statement in ~/.bashrc:
export JAVA_HOME=/home/rahul/Softwares/android-studio/jre
Sample for Mac users:
export JAVA_HOME="/Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/jre"
Since Android Studio 4.2 runs with java 11 instead of java 8, you might also notice this error upon your Android Studio upgrade if you are pointing JAVA_HOME
toward your AS bundled jdk. (See also)
To recover:
Matching Java Virtual Machines (2):
15.0.1, x86_64: "OpenJDK 15.0.1" <path to have home1>
1.8.0_291, x86_64: "Java SE 8" <path to have home2>
export JAVA_HOME="/Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/jre"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With