Android Studio: Difference between revisions
Jump to navigation
Jump to search
Created page with "=Issue with SdkManager= ==Problem== <syntaxhighlight lang="bash"> sdkmanager Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema at..." |
|||
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
=Tips and Tricks= | |||
*Search for intellij for help if not found | |||
*Import Sample if struggling | |||
*Right Click generate getters and setters (Goto coding styles to set m_, s for statics) | |||
*Use blue arrow to run to cursor when debugging | |||
*Lighting bolt applies changes to reduce restart | |||
*LHS in debug is a structure tab to should locals | |||
*Wrap logcat using soft wrap | |||
*Right-click build and select project structure to change build | |||
=Issue with SdkManager= | =Issue with SdkManager= | ||
==Problem== | ==Problem== | ||
Line 44: | Line 55: | ||
export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64 | export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64 | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=Debugging= | |||
We can stop on exception by going to run->view breakpoints. Tick Any Exception and When any is thrown. But the important box is Disable until hitting the following breakpoints. This is because most apps throw many exceptions in normal use. Find where is last worked, add a breakpoint and use the dropbox. | |||
[[File:Android Stop on exception.png|700px]] |
Latest revision as of 23:21, 10 March 2021
Tips and Tricks
- Search for intellij for help if not found
- Import Sample if struggling
- Right Click generate getters and setters (Goto coding styles to set m_, s for statics)
- Use blue arrow to run to cursor when debugging
- Lighting bolt applies changes to reduce restart
- LHS in debug is a structure tab to should locals
- Wrap logcat using soft wrap
- Right-click build and select project structure to change build
Issue with SdkManager
Problem
sdkmanager
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:581)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
... 5 more
Resolution
Make sure you have Java 11 (probably the cause)
sudo update-alternatives --config java
// Select /usr/lib/jvm/java-11-openjdk-amd64/bin/java
Fix it by
cd ~/Android/Sdk/tools
mkdir jaxb_lib
wget https://repo1.maven.org/maven2/javax/activation/activation/1.1.1/activation-1.1.1.jar -O jaxb_lib/activation.jar
wget https://repo1.maven.org/maven2/com/sun/xml/bind/jaxb-impl/2.3.3/jaxb-impl-2.3.3.jar -O jaxb_lib/jaxb-impl.jar
wget https://repo1.maven.org/maven2/com/sun/istack/istack-commons-runtime/3.0.11/istack-commons-runtime-3.0.11.jar -O jaxb_lib/istack-commons-runtime.jar
wget https://repo1.maven.org/maven2/org/glassfish/jaxb/jaxb-xjc/2.3.3/jaxb-xjc-2.3.3.jar -O jaxb_lib/jaxb-xjc.jar
wget https://repo1.maven.org/maven2/org/glassfish/jaxb/jaxb-core/2.3.0.1/jaxb-core-2.3.0.1.jar -O jaxb_lib/jaxb-core.jar
wget https://repo1.maven.org/maven2/org/glassfish/jaxb/jaxb-jxc/2.3.3/jaxb-jxc-2.3.3.jar -O jaxb_lib/jaxb-jxc.jar
wget https://repo1.maven.org/maven2/javax/xml/bind/jaxb-api/2.3.1/jaxb-api-2.3.1.jar -O jaxb_lib/jaxb-api.jar
# Append jaxb_lib to the CLASSPATH in sdkmanager and avdmanager
sed -ie 's%^CLASSPATH=.*%\0:$APP_HOME/jaxb_lib/*%' bin/sdkmanager bin/avdmanager
Set up .bashrc
export ANDROID_HOME=$HOME/Android/Sdk
export PATH=$PATH:$ANDROID_HOME/emulator
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/tools/bin
export PATH=$PATH:$ANDROID_HOME/platform-tools
export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64
Debugging
We can stop on exception by going to run->view breakpoints. Tick Any Exception and When any is thrown. But the important box is Disable until hitting the following breakpoints. This is because most apps throw many exceptions in normal use. Find where is last worked, add a breakpoint and use the dropbox.