(Android) java.lang.NoClassDefFoundError: Failed resolution of: Ljavax/xml/stream/XMLInputFactory
See original GitHub issueI am trying to deserialise some XML and am getting the following exception.
I have these includes: implementation “com.fasterxml.jackson.module:jackson-module-kotlin:2.13.2” implementation(“com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.13.2”) implementation(“com.fasterxml.woodstox:woodstox-core:6.2.8”)
I can serialise/deserialize json fine, the issue is just with XML.
java.lang.NoSuchMethodError: No static method newFactory(Ljava/lang/String;Ljava/lang/ClassLoader;)Ljavax/xml/stream/XMLInputFactory; in class Ljavax/xml/stream/XMLInputFactory; or its super classes (declaration of 'javax.xml.stream.XMLInputFactory' appears in /data/app/~~uieaA4ZwQHgkIyUGH_LkxA==/com.clashcaddie.clashcaddie-xRbKiEW2_xNYMI-cfwHckQ==/base.apk!classes14.dex) at com.fasterxml.jackson.dataformat.xml.XmlFactory.<init>(XmlFactory.java:115) at com.fasterxml.jackson.dataformat.xml.XmlFactory.<init>(XmlFactory.java:101) at com.fasterxml.jackson.dataformat.xml.XmlFactory.<init>(XmlFactory.java:85) at com.fasterxml.jackson.dataformat.xml.XmlMapper.<init>(XmlMapper.java:127) at com.clashcaddie.clashcaddie.ui.caddieoverlay.GridSettingsOverlayViewModel.saveGrids(GridSettingsOverlayViewModel.kt:69) at com.clashcaddie.clashcaddie.ui.caddieoverlay.GridSettingsOverlayViewModel.applyGrids(GridSettingsOverlayViewModel.kt:53) at com.clashcaddie.clashcaddie.databinding.ActivityGridSettingsOverlayBindingImpl._internalCallbackOnClick(ActivityGridSettingsOverlayBindingImpl.java:283) at com.clashcaddie.clashcaddie.generated.callback.OnClickListener.onClick(OnClickListener.java:11) at android.view.View.performClick(View.java:7455) at android.view.View.performClickInternal(View.java:7432) at android.view.View.access$3700(View.java:835) at android.view.View$PerformClick.run(View.java:28810) at android.os.Handler.handleCallback(Handler.java:938) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loopOnce(Looper.java:201) at android.os.Looper.loop(Looper.java:288) at android.app.ActivityThread.main(ActivityThread.java:7842) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
2022-06-22 13:54:26.194 17351-17351/com.clashcaddie.clashcaddie E/AndroidRuntime: FATAL EXCEPTION: main Process: com.clashcaddie.clashcaddie, PID: 17351 java.lang.NoClassDefFoundError: Failed resolution of: Ljavax/xml/stream/XMLInputFactory; at com.fasterxml.jackson.dataformat.xml.XmlFactory.<init>(XmlFactory.java:115) at com.fasterxml.jackson.dataformat.xml.XmlFactory.<init>(XmlFactory.java:101) at com.fasterxml.jackson.dataformat.xml.XmlFactory.<init>(XmlFactory.java:85) at com.fasterxml.jackson.dataformat.xml.XmlMapper.<init>(XmlMapper.java:127) at com.clashcaddie.clashcaddie.ui.caddieoverlay.GridSettingsOverlayViewModel.saveGrids(GridSettingsOverlayViewModel.kt:66) at com.clashcaddie.clashcaddie.ui.caddieoverlay.GridSettingsOverlayViewModel.applyGrids(GridSettingsOverlayViewModel.kt:50) at com.clashcaddie.clashcaddie.databinding.ActivityGridSettingsOverlayBindingImpl._internalCallbackOnClick(ActivityGridSettingsOverlayBindingImpl.java:283) at com.clashcaddie.clashcaddie.generated.callback.OnClickListener.onClick(OnClickListener.java:11) at android.view.View.performClick(View.java:7455) at android.view.View.performClickInternal(View.java:7432) at android.view.View.access$3700(View.java:835) at android.view.View$PerformClick.run(View.java:28810) at android.os.Handler.handleCallback(Handler.java:938) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loopOnce(Looper.java:201) at android.os.Looper.loop(Looper.java:288) at android.app.ActivityThread.main(ActivityThread.java:7842) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003) Caused by: java.lang.ClassNotFoundException: Didn't find class "javax.xml.stream.XMLInputFactory" on path: DexPathList[[dex file "/data/data/com.clashcaddie.clashcaddie/code_cache/.overlay/base.apk/classes4.dex", dex file "/data/data/com.clashcaddie.clashcaddie/code_cache/.overlay/base.apk/classes.dex", dex file "/data/data/com.clashcaddie.clashcaddie/code_cache/.overlay/base.apk/classes14.dex", zip file "/data/app/~~NbB0p3D0j-XgvmhaM3JYmg==/com.clashcaddie.clashcaddie-cnHJSvUA99dufgkz2-Gs7g==/base.apk"],nativeLibraryDirectories=[/data/app/~~NbB0p3D0j-XgvmhaM3JYmg==/com.clashcaddie.clashcaddie-cnHJSvUA99dufgkz2-Gs7g==/lib/arm64, /system/lib64, /system_ext/lib64]] at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:218) at java.lang.ClassLoader.loadClass(ClassLoader.java:379) at java.lang.ClassLoader.loadClass(ClassLoader.java:312) at com.fasterxml.jackson.dataformat.xml.XmlFactory.<init>(XmlFactory.java:115) at com.fasterxml.jackson.dataformat.xml.XmlFactory.<init>(XmlFactory.java:101) at com.fasterxml.jackson.dataformat.xml.XmlFactory.<init>(XmlFactory.java:85) at com.fasterxml.jackson.dataformat.xml.XmlMapper.<init>(XmlMapper.java:127) at com.clashcaddie.clashcaddie.ui.caddieoverlay.GridSettingsOverlayViewModel.saveGrids(GridSettingsOverlayViewModel.kt:66) at com.clashcaddie.clashcaddie.ui.caddieoverlay.GridSettingsOverlayViewModel.applyGrids(GridSettingsOverlayViewModel.kt:50) at com.clashcaddie.clashcaddie.databinding.ActivityGridSettingsOverlayBindingImpl._internalCallbackOnClick(ActivityGridSettingsOverlayBindingImpl.java:283) at com.clashcaddie.clashcaddie.generated.callback.OnClickListener.onClick(OnClickListener.java:11) at android.view.View.performClick(View.java:7455) at android.view.View.performClickInternal(View.java:7432) at android.view.View.access$3700(View.java:835) at android.view.View$PerformClick.run(View.java:28810) at android.os.Handler.handleCallback(Handler.java:938) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loopOnce(Looper.java:201) at android.os.Looper.loop(Looper.java:288) at android.app.ActivityThread.main(ActivityThread.java:7842) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
Issue Analytics
- State:
- Created a year ago
- Comments:8 (4 by maintainers)
Top GitHub Comments
@clashcaddie
After adding
implementation 'javax.xml.stream:stax-api:1.0-2'
to my dependencies the following works for me:Ah… that’s unfortunate but not surprising. I would take a PR against 2.14 to use the old “deprecated” method if that helps Android compatibility.