Skip to content
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

Unexpected reference to missing service class #109

Closed
Basheer009 opened this issue Nov 2, 2023 · 6 comments
Closed

Unexpected reference to missing service class #109

Basheer009 opened this issue Nov 2, 2023 · 6 comments

Comments

@Basheer009
Copy link

I got this when building APK

Unexpected reference to missing service class: META-INF/services/javax.xml.stream.XMLEventFactory.
Unexpected reference to missing service class: META-INF/services/javax.xml.stream.XMLInputFactory.
Unexpected reference to missing service class: META-INF/services/javax.xml.stream.XMLOutputFactory.

@centic9
Copy link
Owner

centic9 commented Nov 4, 2023

With "building APK", you mean the test-app that is included in this project, right?

Which version of JDK are you using?

Any local changes?

Do you have the system properties in place that are described at https://github.com/centic9/poi-on-android#necessary-system-properties.

And please provide the full output if there is more.

@Basheer009
Copy link
Author

Basheer009 commented Nov 23, 2023

Sorry for late reply, Building APK I mean creating a release, minifyEnabled true
and I have applied the proguard-rules.pro config as described in this repo

My JDK is 11.0.16
and Yes I have added the system properties like this:

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");

in my App class which extends Application

Task :app:minifyReleaseWithR8
AGPBI: {"kind":"warning","text":"Unexpected reference to missing service class: META-INF/services/javax.xml.stream.XMLEventFactory.","sources":[{"file":"C:\AndroidProjects\CIDApp\app\build\intermediates\merged_java_res\release\base.jar"}],"tool":"R8"}
AGPBI: {"kind":"warning","text":"Unexpected reference to missing service class: META-INF/services/javax.xml.stream.XMLInputFactory.","sources":[{"file":"C:\AndroidProjects\CIDApp\app\build\intermediates\merged_java_res\release\base.jar"}],"tool":"R8"}
AGPBI: {"kind":"warning","text":"Unexpected reference to missing service class: META-INF/services/javax.xml.stream.XMLOutputFactory.","sources":[{"file":"C:\AndroidProjects\CIDApp\app\build\intermediates\merged_java_res\release\base.jar"}],"tool":"R8"}

@EliAgne
Copy link
Contributor

EliAgne commented Apr 4, 2024

Could you provide the MainActivity or app java, build gradle and proguard files? It's difficult to determine the issue with the information given.

@Basheer009
Copy link
Author

in my proguard file:

`# for excel use

Apache POI

-dontwarn org.apache.**
-dontwarn org.openxmlformats.schemas.**
-dontwarn org.etsi.**
-dontwarn org.w3.**
-dontwarn com.microsoft.schemas.**
-dontwarn com.graphbuilder.**
-dontwarn javax.naming.**
-dontwarn java.lang.management.**
-dontwarn org.slf4j.impl.**
-dontwarn java.awt.**
-dontwarn net.sf.saxon.**
-dontwarn org.apache.batik.**
-dontwarn org.apache.logging.log4j.**

-dontnote org.apache.**
-dontnote org.openxmlformats.schemas.**
-dontnote org.etsi.**
-dontnote org.w3.**
-dontnote com.microsoft.schemas.**
-dontnote com.graphbuilder.**
-dontnote javax.naming.**
-dontnote java.lang.management.**
-dontnote org.slf4j.impl.**

-keeppackagenames org.apache.poi.ss.formula.function

-keep,allowoptimization,allowobfuscation class org.apache.logging.log4j.** { ; }
-keep,allowoptimization class org.apache.commons.compress.archivers.zip.
* { ; }
-keep,allowoptimization class org.apache.poi.schemas.
* { ; }
-keep,allowoptimization class org.apache.xmlbeans.
* { ; }
-keep,allowoptimization class org.openxmlformats.schemas.
* { ; }
-keep,allowoptimization class com.microsoft.schemas.
* { *; }
`

my app java file at onCreate

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 what i get when building release app
Screenshot 2024-04-08 004342

@centic9
Copy link
Owner

centic9 commented Apr 10, 2024

These are just warnings, right?

Is anything not working because of this or are you just curious about the warnings?

Android is missing some parts of normal JDK, this is why the setProperty()-calls are necessasry, the warnings might be remnants of this and may be hard to avoid here.

@centic9
Copy link
Owner

centic9 commented Apr 10, 2024

I have now excluded those files from the poi-shadow-all.jar to remove the warning.

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

3 participants