FATAL EXCEPTION in Android
Closed this issue · 6 comments
When I try to save the gpx file by directly depending on "io.jenetics:jpx:3.0.1" through Gradle and calling theGPX.write(gpx, path)
method, an FATAL EXCEPTION is prompted. After troubleshooting, it is found that this dependency exists in both Android33 and jdk17. here is the exception stack trace is:
FATAL EXCEPTION: DefaultDispatcher-worker-3
Process: com.example.heystestdemo, PID: 20783
javax.xml.stream.FactoryConfigurationError: Provider com.bea.xml.stream.XMLOutputFactoryBase not found
at javax.xml.stream.FactoryFinder.newInstance(FactoryFinder.java:72)
at javax.xml.stream.FactoryFinder.find(FactoryFinder.java:176)
at javax.xml.stream.FactoryFinder.find(FactoryFinder.java:92)
at javax.xml.stream.XMLOutputFactory.newInstance(XMLOutputFactory.java:98)
at io.jenetics.jpx.XMLProvider.xmlOutputFactory(XMLProvider.java:64)
at io.jenetics.jpx.GPX$Writer.write(GPX.java:1487)
at io.jenetics.jpx.GPX$Writer.write(GPX.java:1526)
at io.jenetics.jpx.GPX$Writer.write(GPX.java:1542)
at io.jenetics.jpx.GPX.write(GPX.java:2075)
the javax.xml.stream.XMLInputFactory
and javax.xml.stream.XMLOutputFactory
exists in both Android33 and jdk17
The exception says, that the class com.bea.xml.stream.XMLOutputFactoryBase
is missing.
The following statements are some of my speculations about this issue:
Since the classloader does not load other classes with the same name when it discovers that a certain class already exists, and in the Android system, the class loader gives priority to loading classes related to the Android API. Therefore, the classes with the same name in JDK are skipped. In this case, the XMLOutputFactory
class in the javax.xml.stream
package of the Android API is loaded first, thereby missing the other classes we need in the JDK package.but this causes us to miss other classes we need from the JDK package. Thus, during the subsequent loading process of packages with the same name, the class loader is unable to load XMLOutputFactoryBase, and as a result, it throws the missing message.
I want to use your library in my Android application, but it seems not to work properly, so I've raised this issue in the hope of getting some assistance.
When I updated my dependencies according to the solution of issues 76, it seems to work well.
implementation("io.jenetics:jpx:2.2.0")
implementation("stax:stax-api:1.0.1")
implementation("com.fasterxml:aalto-xml:1.3.0")
But another problem arose when I updated your library to the latest version(io.jenetics:jpx:3.0.1).
FATAL EXCEPTION: DefaultDispatcher-worker-1
Process: com.example.heystestdemo, PID: 10108
java.lang.IllegalAccessError: Method 'void io.jenetics.jpx.XMLWriter.lambda$map$0(java.util.function.Function, javax.xml.stream.XMLStreamWriter, java.lang.Object)' is inaccessible to class 'io.jenetics.jpx.XMLWriter$$ExternalSyntheticLambda2'
at io.jenetics.jpx.XMLWriter$$ExternalSyntheticLambda2.write(Unknown Source:4)
at io.jenetics.jpx.XMLWriter.lambda$elem$4(XMLWriter.java:164)
at io.jenetics.jpx.XMLWriter$$ExternalSyntheticLambda5.write(Unknown Source:4)
at io.jenetics.jpx.GPX$Writer.write(GPX.java:1502)
at io.jenetics.jpx.GPX$Writer.write(GPX.java:1526)
at io.jenetics.jpx.GPX$Writer.write(GPX.java:1542)
at io.jenetics.jpx.GPX.write(GPX.java:2075)
But anyway, the problem seems to be solved, thanks a lot for your help.
I tried all possible versions, including this last one:
implementation("io.jenetics:jpx:3.1.0")
implementation("stax:stax-api:1.0.1")
implementation("com.fasterxml:aalto-xml:1.3.1")
These are my project settings:
Android Gradle Plugin version 8.3.2
Gradle Version 8.4
$JavaVersion.VERSION_17
minSdkVersion 28
targetSdkVersion 34
compileSdk 34
but I keep getting several errors related to the XML parser.
With the settings above:
java.lang.NoSuchMethodError: No interface method toList()Ljava/util/List; in class Ljava/util/stream/Stream; or its super classes (declaration of 'java.util.stream.Stream' appears in /apex/com.android.art/javalib/core-oj.jar)
at io.jenetics.jpx.ElemReader.read(XMLReader.java:605)
at io.jenetics.jpx.GPX$Reader.read(GPX.java:1181)
at io.jenetics.jpx.GPX$Reader.read(GPX.java:1213)
at io.jenetics.jpx.GPX$Reader.read(GPX.java:1229)
at io.jenetics.jpx.GPX.read(GPX.java:2094)
Has anyone found the solution?