bubblewrap
bubblewrap copied to clipboard
bubblewrap build throws NoClassDefFoundError for javax.xml.bind.annotation.XmlSchema
$ bubblewrap init -manifest …
[…]
Project generated successfully. Build it by running bubblewrap build
$ bubblewrap build
[…]
Installing Android Build Tools. Please, read and accept the license agreement.
build Installing Build Tools
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
cli ERROR undefined
$ java --version
openjdk 11.0.19 2023-04-18 LTS
OpenJDK Runtime Environment Zulu11.64+19-CA (build 11.0.19+7-LTS)
OpenJDK 64-Bit Server VM Zulu11.64+19-CA (build 11.0.19+7-LTS, mixed mode)
$ bubblewrap --version
[…]
version 1.20.0
$ lsb_release -d
Description: Ubuntu 22.04.2 LTS
Describe the bug
After setting up the bubblewrap project with bubblewrap init --manifest …, bubblewrap instructed me to run bubblewrap build. So I did. That leads to above exception.
To Reproduce Steps to reproduce the behavior:
$ bubblewrap init --manifest …
$ bubblewrap build
Expected behavior Builds the TWA.
Actual behavior
Throws an exception about javax.xml.bind.annotation.XmlSchema.
Desktop (please complete the following information):
- OS: Linux (Ubuntu 22.04.2 LTS)
- Java: openjdk 11.0.19 2023-04-18 LTS Zulu11.64+19-CA (build 11.0.19+7-LTS)
- bubblewrap version 1.20.0
Hum, this bit seems to come from the Android SDK (Bubblewrap only does a passthrough call here). See https://stackoverflow.com/questions/46402772/failed-to-install-android-sdk-java-lang-noclassdeffounderror-javax-xml-bind-a.
Installing Android Build Tools. Please, read and accept the license agreement.
build Installing Build Tools
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
This also happens when I let Bubblewrap choose and install the JDK.
$ bubblewrap init --manifest https://monitor.nelkinda.com/
,-----. ,--. ,--. ,--.
| |) /_,--.,--| |-.| |-.| |,---.,--. ,--,--.--.,--,--.,---.
| .-. | || | .-. | .-. | | .-. | |.'.| | .--' ,-. | .-. |
| '--' ' '' | `-' | `-' | \ --| .'. | | \ '-' | '-' '
`------' `----' `---' `---'`--'`----'--' '--`--' `--`--| |-'
`--'
? Do you want Bubblewrap to install JDK?
(Enter "No" to use your JDK installation) Yes
Downloading JDK 11 to /home/christian.hujer/.bubblewrap/jdk
Downloading the JDK 11 Sources...
>> [████████████████████████████████████████] 100% | 188831k of 185929k
Decompressing the JDK 11 Sources...
Downloading the JDK 11 Binaries...
>> [████████████████████████████████████████] 100% | 190160k of 190160k
Decompressing the JDK 11 Binaries...
Extracting /home/christian.hujer/.bubblewrap/jdk/OpenJDK11U-jdk_x64_linux_hotspot_11.0.9.1_1.tar.gz to /home/christian.hujer/.bubblewrap/jdk
? Do you want Bubblewrap to install Android SDK?
(Enter "No" to use your installation) No
? Path to your existing Android SDK: /home/christian.hujer/Android/Sdk/
[…]
$ bubblewrap build
,-----. ,--. ,--. ,--.
| |) /_,--.,--| |-.| |-.| |,---.,--. ,--,--.--.,--,--.,---.
| .-. | || | .-. | .-. | | .-. | |.'.| | .--' ,-. | .-. |
| '--' ' '' | `-' | `-' | \ --| .'. | | \ '-' | '-' '
`------' `----' `---' `---'`--'`----'--' '--`--' `--`--| |-'
`--'
Installing Android Build Tools. Please, read and accept the license agreement.
build Installing Build Tools
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
cli ERROR undefined
/home/christian.hujer/.bubblewrap/config.json now points the JDK to /home/christian.hujer/.bubblewrap/jdk/jdk-11.0.9.1+1 and that has the same issue.
JDK 8 seems to work (in my case /home/christian.hujer/.sdkman/candidates/java/8.0.302-open/)
Newer SDK Tools versions support JDK 11. My guess is that the SDK Tools at /home/christian.hujer/Android/Sdk/ is outdated, therefore fails with JDK 11, but works with JDK 8.
Newer SDK Tools versions support JDK 11. My guess is that the SDK Tools at
/home/christian.hujer/Android/Sdk/is outdated, therefore fails with JDK 11, but works with JDK 8.
Hmm. Shouldn't be the case, but who knows? I'll double-check and will let you know.
Has this worked out by using the Android SDK installed by Bubblewrap?
@christianhujer did you manage to solve it?
I had the same error, then I tried replacing android sdk tools with the latest version downloaded from https://developer.android.com/studio/ and now I'm getting a different error:
build Installing Build Tools
Error: LinkageError occurred while loading main class com.android.sdklib.tool.sdkmanager.SdkManagerCli
java.lang.UnsupportedClassVersionError: com/android/sdklib/tool/sdkmanager/SdkManagerCli has been compiled by a more recent version of the Java Runtime (class file version 61.0), this version of the Java Runtime only recognizes class file versions up to 55.0
55.0 means Java 11, looks like the latest build tools are not compatible with this version, and we must use it for bubblewrap to work. Or am I missing something?
C:\Projects\Flyent\Flyent\client\android>java --version
java 17.0.8 2023-07-18 LTS
Java(TM) SE Runtime Environment (build 17.0.8+9-LTS-211)
Java HotSpot(TM) 64-Bit Server VM (build 17.0.8+9-LTS-211, mixed mode, sharing)
Worked for me when I reinstalled bot SDKs using Bubblewrap.
This build issue needs to be consolidated into one ticket, as they all seem related ( bubblewrap build doesn't work)
https://github.com/GoogleChromeLabs/bubblewrap/issues/833 https://github.com/GoogleChromeLabs/bubblewrap/issues/606 https://github.com/GoogleChromeLabs/bubblewrap/issues/738
Duplicate of #606