Skip to content

cucumber-android not working because Android is missing javax.xml.stream.* #36

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Hsilgos opened this issue Jul 15, 2024 · 2 comments
Closed

Comments

@Hsilgos
Copy link

Hsilgos commented Jul 15, 2024

👓 What did you see?

Hi

During compilation I faced R8 error that javax.xml.stream.* are missing:

ERROR: R8: Missing class javax.xml.stream.XMLOutputFactory (referenced from: void io.cucumber.junitxmlformatter.XmlReportWriter.writeXmlReport(java.io.Writer))
Missing class javax.xml.stream.XMLStreamWriter (referenced from: javax.xml.stream.XMLStreamWriter io.cucumber.junitxmlformatter.EscapingXmlStreamWriter.writer and 12 other contexts)

If I suppress the error with

-dontwarn javax.xml.stream.XMLOutputFactory
-dontwarn javax.xml.stream.XMLStreamWriter

I see runtime error

[2024-07-15T13:10:52.712+00:00Z] There was 1 failure:
[2024-07-15T13:10:52.712+00:00Z] 1) io.cucumber.android.CucumberJUnitRunnerBuilder
[2024-07-15T13:10:52.712+00:00Z] java.lang.NoClassDefFoundError: Failed resolution of: Ljavax/xml/stream/XMLOutputFactory;
[2024-07-15T13:10:52.712+00:00Z] 	at io.cucumber.junitxmlformatter.XmlReportWriter.writeXmlReport(XmlReportWriter.java:30)
[2024-07-15T13:10:52.712+00:00Z] 	at io.cucumber.junitxmlformatter.MessagesToJunitXmlWriter.close(MessagesToJunitXmlWriter.java:60)
[2024-07-15T13:10:52.712+00:00Z] 	at io.cucumber.core.plugin.JUnitFormatter.write(JUnitFormatter.java:35)
[2024-07-15T13:10:52.712+00:00Z] 	at io.cucumber.core.plugin.JUnitFormatter.$r8$lambda$lIOZf2g96s60oX1b0tjdfI5LY_s(Unknown Source:0)
...

Looking through SO I found a workaround to add 16 years old library:

androidTestImplementation "javax.xml.stream:stax-api:1.0-2"

which help a little bit, but still the new error:

[2024-07-15T15:43:39.219+00:00Z] INSTRUMENTATION_STATUS: stack=javax.xml.stream.FactoryConfigurationError: Provider com.bea.xml.stream.XMLOutputFactoryBase not found
[2024-07-15T15:43:39.219+00:00Z] 	at javax.xml.stream.FactoryFinder.newInstance(FactoryFinder.java:72)
[2024-07-15T15:43:39.219+00:00Z] 	at javax.xml.stream.FactoryFinder.find(FactoryFinder.java:176)
[2024-07-15T15:43:39.219+00:00Z] 	at javax.xml.stream.FactoryFinder.find(FactoryFinder.java:92)
[2024-07-15T15:43:39.219+00:00Z] 	at javax.xml.stream.XMLOutputFactory.newInstance(XMLOutputFactory.java:98)
[2024-07-15T15:43:39.219+00:00Z] 	at io.cucumber.junitxmlformatter.XmlReportWriter.writeXmlReport(XmlReportWriter.java:30)
[2024-07-15T15:43:39.219+00:00Z] 	at io.cucumber.junitxmlformatter.MessagesToJunitXmlWriter.close(MessagesToJunitXmlWriter.java:60)
[2024-07-15T15:43:39.219+00:00Z] 	at io.cucumber.core.plugin.JUnitFormatter.write(JUnitFormatter.java:35)
...

I believe this one can be fixed with such approach FasterXML/jackson-dataformat-xml#583

✅ What did you expect to see?

Success compilation and no issues runtime

📦 Which tool/library version are you using?

cucumber-android 7.14.0
Android API 29
JDK 17

🔬 How could we reproduce it?

No response

📚 Any additional context?

No response

@mpkorstanje
Copy link
Contributor

mpkorstanje commented Jul 16, 2024

I don't immediately see how FasterXML/jackson-dataformat-xml#583 would fix the issue. The PR changes .newFactory() to .newInstance() which is already used here. It also looks like there may be something else going on. The error message you got doesn't quite match the one from FasterXML, but rather alipov/ews-android-api#8.

I also don't have anything setup for Android so I can't test or verify anything. But if you can provide a pull request I'd be happy to accept it.

@Hsilgos
Copy link
Author

Hsilgos commented Jul 16, 2024

@mpkorstanje , my bad. Thanks for pointing it out.. This solved the problem:

androidTestImplementation 'com.fasterxml:aalto-xml:1.3.3'

@Hsilgos Hsilgos closed this as completed Jul 16, 2024
mpkorstanje added a commit that referenced this issue Jul 16, 2024
mpkorstanje added a commit to cucumber/testng-xml-formatter that referenced this issue Jul 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants