I'm developing an app for android. I want create a docx file with my app and i use Docx4j for this job. my app hasn't any error when compiled but when run app and touch button for create file, app is crashed.
this is error when crash:
- Code: Select all
E/AndroidRuntime: FATAL EXCEPTION: main
Process: ir.hezare.kateb, PID: 18903
javax.xml.stream.FactoryConfigurationError: Provider com.bea.xml.stream.MXParserFactory 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.XMLInputFactory.newInstance(XMLInputFactory.java:136)
at org.docx4j.openpackaging.parts.JaxbXmlPartXPathAware.unmarshal(JaxbXmlPartXPathAware.java:432)
at org.docx4j.openpackaging.parts.JaxbXmlPartXPathAware.unmarshal(JaxbXmlPartXPathAware.java:346)
at org.docx4j.openpackaging.parts.WordprocessingML.StyleDefinitionsPart.unmarshalDefaultStyles(StyleDefinitionsPart.java:155)
at org.docx4j.openpackaging.packages.WordprocessingMLPackage.createPackage(WordprocessingMLPackage.java:457)
at org.docx4j.openpackaging.packages.WordprocessingMLPackage.createPackage(WordprocessingMLPackage.java:406)
at ir.hezare.kateb.Class.CreateDoc.runDoc(CreateDoc.java:97)
at ir.hezare.kateb.Activity.PrintActivity.btnSaveDoc(PrintActivity.java:754)
at ir.hezare.kateb.Activity.PrintActivity.access$000(PrintActivity.java:81)
at ir.hezare.kateb.Activity.PrintActivity$1.onClick(PrintActivity.java:153)
at android.view.View.performClick(View.java:4856)
at android.view.View$PerformClick.run(View.java:19956)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:211)
at android.app.ActivityThread.main(ActivityThread.java:5389)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1020)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:815)
I use this Library in my app:
- Code: Select all
compile group: 'org.docx4j', name: 'docx4j', version: '3.3.6'
compile group: 'org.docx4j', name: 'docx4j-MOXy-JAXBContext', version: '3.3.6'
compile group: 'javax.xml.bind', name: 'jaxb-api', version: '2.1'
compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.25'
and this is my code:
- Code: Select all
WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.createPackage();
MainDocumentPart mdp = wordMLPackage.getMainDocumentPart();
mdp.addParagraphOfText("hello world");
Docx4J.save(wordMLPackage, new java.io.File(filename), Docx4J.FLAG_SAVE_ZIP_FILE);
Please help me. thanks.