We have and Android app and when we updated smack from 4.3.4 to 4.4.6 we started seeing crashes for some users. We didn’t change anything else.
Exception:
Caused by java.lang.IllegalStateException
No XmlPullParserFactory registered with Service Provider Interface (SPI). Is smack-xmlparser-xpp3 or smack-xmlparser-stax in classpath?
Stack trace:
org.jivesoftware.smack.xml.SmackXmlParser.getXmlPullParserFactory (SmackXmlParser.java:41)
org.jivesoftware.smack.xml.SmackXmlParser.newXmlParser (SmackXmlParser.java:65)
org.jivesoftware.smack.util.PacketParserUtils.getParserFor (PacketParserUtils.java:80)
org.jivesoftware.smack.SmackInitialization.processConfigFile (SmackInitialization.java:159)
org.jivesoftware.smack.SmackInitialization.processConfigFile (SmackInitialization.java:154)
org.jivesoftware.smack.SmackInitialization.<clinit> (SmackInitialization.java:103)
org.jivesoftware.smack.Smack.getVersion (Smack.java:38)
org.jivesoftware.smack.Smack.ensureInitialized (Smack.java:64)
org.jivesoftware.smack.ConnectionConfiguration.<clinit> (ConnectionConfiguration.java:116)
org.jivesoftware.smack.tcp.XMPPTCPConnectionConfiguration.builder (XMPPTCPConnectionConfiguration.java:64)
The only thing we saw from the data we had was that this happened only for the users for which the app was started from the MediaBrowserService we implement (could be Android Auto but not sure).
We didn’t see any crash for normal app start and all our tests succeeded.
I don’t think I understand the question. All we know is that since we upgraded smack to 4.4.6 we saw in crashlytics a lot of crashes while with 4.3.4 we didn’t have any. So we had to revert to 4.3.4.
How can I find the information you need? Isn’t there a way to use smack on those devices? I mean, it worked with 4.3.4 (at least we didn’t see any reason it didn’t work).
Do you use ProGuard or similar code obfuscation and optimization tools? If so, does the error also appear if you disable it? It is possible that those tools throw away the SPI implementations, causing this exception.
We use ProGuard but we don’t have any issues when testing on our own devices (several models and Android versions). And only some users seem to get the exception and for them the app is always started via a service.
We have these (I guess relevant) lines in the ProGuard file:
-keep class org.xmlpull.v1.** {*;}
-keep class org.jivesoftware.** { *; }
Just to be sure, you mean call it like this?
SmackXmlParser.setXmlPullParserFactory(new Xpp3XmlPullParserFactory());
When I debug SmackXmlParser.newXmlParser() I see it returning an Xpp3XmlPullParserFactory object.
So it looks like in both cases the same factory class would be used (on Android at least).
Would there be any disadvantage of using the workaround?