GithubHelp home page GithubHelp logo

Cannot get it to work about poi-on-android HOT 13 CLOSED

centic9 avatar centic9 commented on May 23, 2024
Cannot get it to work

from poi-on-android.

Comments (13)

centic9 avatar centic9 commented on May 23, 2024

If this is still a problem then please paste the full build-output as the one line is likely not the actual cause.

from poi-on-android.

stan2100 avatar stan2100 commented on May 23, 2024

Hi,
the build process in android studio finishes with a lot of errors, but the app gets installed on my phone. When I try to create an excel file, with my app installed on the phone, android studio will show the following errors. https://github.com/andruhon/android5xlsx works for me, that’s why I have stopped trying to get it work.
If you like I could close the issue. Or if you like, I could test some different setups/configurations.
Thank you for your help!

org.apache.poi.javax.xml.stream.FactoryConfigurationError: Provider com.bea.xml.stream.EventFactory not found
at org.apache.poi.javax.xml.stream.FactoryFinder.newInstance(FactoryFinder.java:72)
at org.apache.poi.javax.xml.stream.FactoryFinder.find(FactoryFinder.java:178)
at org.apache.poi.javax.xml.stream.FactoryFinder.find(FactoryFinder.java:92)
at org.apache.poi.javax.xml.stream.XMLEventFactory.newInstance(XMLEventFactory.java:30)
at org.apache.poi.openxml4j.opc.internal.marshallers.PackagePropertiesMarshaller.(PackagePropertiesMarshaller.java:41)
at org.apache.poi.openxml4j.opc.OPCPackage.init(OPCPackage.java:161)
at org.apache.poi.openxml4j.opc.OPCPackage.(OPCPackage.java:141)
at org.apache.poi.openxml4j.opc.ZipPackage.(ZipPackage.java:72)
at org.apache.poi.openxml4j.opc.OPCPackage.create(OPCPackage.java:394)
at org.apache.poi.xssf.usermodel.XSSFWorkbook.newPackage(XSSFWorkbook.java:475)
at org.apache.poi.xssf.usermodel.XSSFWorkbook.(XSSFWorkbook.java:243)
at org.apache.poi.xssf.usermodel.XSSFWorkbook.(XSSFWorkbook.java:235)
at com.test.com.excel.saveExcelFile(excelexportservice.java:77)
at com.test.com.excel.onCreate(excelexportservice.java:60)
at android.app.ActivityThread.handleCreateService(ActivityThread.java:3807)
at android.app.ActivityThread.access$2100(ActivityThread.java:221)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1882)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:158)
at android.app.ActivityThread.main(ActivityThread.java:7225)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:102)

from poi-on-android.

centic9 avatar centic9 commented on May 23, 2024

The error message indicates that no XML Parser was found at all, however the poi-shadow.jar should already contain the aalto-xml parser implementation which can be used on Android directly in the shadowed jar.

Maybe you can try to not additionally list the aalto-xml as dependency?

from poi-on-android.

stan2100 avatar stan2100 commented on May 23, 2024

Hi,
attached, you will find the build-Log, the app-crash-log, and the build.gradle. Let me know, what I should change. I did the testing in a new project, to make sure, no other settings are the cause for the crash.
App-crash-Log.pdf
build.gradle.pdf
Build-Log.pdf

from poi-on-android.

dreamhappy avatar dreamhappy commented on May 23, 2024

How do you use the android poi insert pictures in word

from poi-on-android.

peterhav avatar peterhav commented on May 23, 2024

Hi, I'm encountering the same issue: using poi 3.16. The lib creation works fine, building my app as well, but at runtime during sheet production the app crashes with:

org.apache.poi.javax.xml.stream.FactoryConfigurationError: Provider com.bea.xml.stream.EventFactory not found
                                                                            at org.apache.poi.javax.xml.stream.FactoryFinder.newInstance(FactoryFinder.java:72)
                                                                            at org.apache.poi.javax.xml.stream.FactoryFinder.find(FactoryFinder.java:178)
                                                                            at org.apache.poi.javax.xml.stream.FactoryFinder.find(FactoryFinder.java:92)
                                                                            at org.apache.poi.javax.xml.stream.XMLEventFactory.newInstance(XMLEventFactory.java:30)
                                                                            at org.apache.poi.openxml4j.opc.internal.marshallers.PackagePropertiesMarshaller.<clinit>(PackagePropertiesMarshaller.java:41)
                                                                            at org.apache.poi.openxml4j.opc.OPCPackage.init(OPCPackage.java:161)
                                                                            at org.apache.poi.openxml4j.opc.OPCPackage.<init>(OPCPackage.java:141)
                                                                            at org.apache.poi.openxml4j.opc.ZipPackage.<init>(ZipPackage.java:72)
                                                                            at org.apache.poi.openxml4j.opc.OPCPackage.create(OPCPackage.java:394)
                                                                            at org.apache.poi.xssf.usermodel.XSSFWorkbook.newPackage(XSSFWorkbook.java:475)
                                                                            at org.apache.poi.xssf.usermodel.XSSFWorkbook.<init>(XSSFWorkbook.java:243)
                                                                            at org.apache.poi.xssf.usermodel.XSSFWorkbook.<init>(XSSFWorkbook.java:235)

from poi-on-android.

centic9 avatar centic9 commented on May 23, 2024

The shaded jar includes the aalto-xml parser and tries to include service-files to make Android load this XML parser instead of the com.bea default one.

What exact version of Android is this?

And can you try try the workaround mentioned in AOSP issue 59658 comment 22:

    right click on /src/main (where you have /java and /res folders),
    select New > Folder > Java Resources Folder,
    click Finish (do not change Folder Location),
    right click on new /resources folder,
    select New > Directory
    enter "META-INF" (without quotes),
    right click on /resources/META-INF folder,
    select New > Directory
    enter "services" (without quotes)
    copy any file you need into /resources/META-INF/services

For you, you'd need to copy this file (javax.xml.stream.XMLInputFactory) into /resources/META-INF/services.

See also the discussion at https://stackoverflow.com/questions/30968735/using-com-bea-xml-stream-package-on-android

from poi-on-android.

peterhav avatar peterhav commented on May 23, 2024

Thanks for the quick reaction. Note that the provided test app works fine on the same emulator (the test.xlsx is created). I will first dive into the differences in my app code and the provided test project before trying the steps mentioned above.

from poi-on-android.

centic9 avatar centic9 commented on May 23, 2024

Yes, that would be very welcome as I have a few similar reports but cannot reproduce it myself, one likely cause would be some additional dependencies on other third party libs which may cause this.

from poi-on-android.

peterhav avatar peterhav commented on May 23, 2024

Hi @centic9,

I was able to fix my app by adding these 3 lines from the sample application:

            System.setProperty("org.apache.poi.javax.xml.stream.XMLInputFactory", "com.fasterxml.aalto.stax.InputFactoryImpl");
            System.setProperty("org.apache.poi.javax.xml.stream.XMLOutputFactory", "com.fasterxml.aalto.stax.OutputFactoryImpl");
            System.setProperty("org.apache.poi.javax.xml.stream.XMLEventFactory", "com.fasterxml.aalto.stax.EventFactoryImpl");

This was not clear from the readme file on the github main page. I guess a short piece of text on the readme might help others!

Thanks for your efforts in providing this fix to make POI available for Android.

Best regards,
Peter

from poi-on-android.

centic9 avatar centic9 commented on May 23, 2024

Thanks a lot for the investigation, that makes sense, I added this a while ago and completely forgot about it, sorry for not mentioning this in the README until now.

i would be interested if there is a better way to do this without having to put something like this into the actual application-code!

from poi-on-android.

albakaly avatar albakaly commented on May 23, 2024

Javax is not included in android that is why we face this error, is there a way to use this lib without javax?

from poi-on-android.

centic9 avatar centic9 commented on May 23, 2024

See the readme and previous comments above for some system properties which make it work.

from poi-on-android.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.