简体   繁体   English

Android Smack初始化:org.xmlpull.v1.XmlPullParserFactory.newInstance错误

[英]Android SmackInitialization: org.xmlpull.v1.XmlPullParserFactory.newInstance Error

I keep getting the below error message and I can't figure out why. 我不断收到以下错误消息,但我不知道为什么。 Any help would be appreciated: 任何帮助,将不胜感激:

Exception in thread "main" java.lang.ExceptionInInitializerError
    at org.jivesoftware.smack.SmackConfiguration.getVersion(SmackConfiguration.java:96)
    at org.jivesoftware.smack.ConnectionConfiguration.<clinit>(ConnectionConfiguration.java:38)
    at com.parental.control.XmppClient.connect(XmppClient.java:32)
    at com.parental.control.XmppClient.main(XmppClient.java:23)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
Caused by: java.lang.IllegalStateException: java.lang.RuntimeException: Stub!
    at org.jivesoftware.smack.SmackInitialization.<clinit>(SmackInitialization.java:119)
    ... 9 more
Caused by: java.lang.RuntimeException: Stub!
    at org.xmlpull.v1.XmlPullParserFactory.newInstance(XmlPullParserFactory.java:16)
    at org.jivesoftware.smack.SmackInitialization.processConfigFile(SmackInitialization.java:153)
    at org.jivesoftware.smack.SmackInitialization.processConfigFile(SmackInitialization.java:148)
    at org.jivesoftware.smack.SmackInitialization.<clinit>(SmackInitialization.java:116)
    ... 9 more

Just running the below code: 只需运行以下代码:

private void connect() throws InterruptedException, IOException, XMPPException, SmackException {
    XMPPTCPConnectionConfiguration conf = XMPPTCPConnectionConfiguration.builder().setServiceName(hostName).setHost(<openFireServerHost).setPort(5222).setUsernameAndPassword(userName, password).setCompressionEnabled(false).build();
    XMPPTCPConnection connection = new XMPPTCPConnection(conf);
}

You have compiled your application with android library stub, read the docs : 您已使用android库存根编译了应用程序,请阅读docs

By default, the Android Plug-in for Gradle executes your local unit tests against a modified version of the android.jar library, which does not contain any actual code . 默认情况下,Android Gradle插件针对android.jar库的修改版本执行本地单元测试, 该版本不包含任何实际代码 Instead, method calls to Android classes from your unit test throw an exception. 相反,从单元测试对Android类的方法调用将引发异常。 This is to make sure you test only your code and do not depend on any particular behavior of the Android platform (that you have not explicitly mocked). 这是为了确保您仅测试代码,并且不依赖于Android平台的任何特定行为(尚未明确模拟)。

So, your build environment isn't configured properly to build a real android application for the device/emulator 因此,您的构建环境未正确配置,无法为设备/模拟器构建真正的android应用程序

So . 这样。 . . this was actually an XMLPullParser error which has nothing to do with the Smack libraries. 这实际上是XMLPullParser错误,与Smack库无关。 It took me all weekend to trace through the code and figure this out but the issue was that I was trying to connect to my Open Fire server without using the my Android emulator. 我花了整个周末的时间来查找代码并找出答案,但是问题是我试图不使用Android模拟器就连接到Open Fire服务器。

The below Stack Overflow post helped me figure it out: how to instantiate an XmlPullParser in android-8? 下面的Stack Overflow帖子帮助我弄清楚了: 如何在android-8中实例化XmlPullParser?

Just figured that I would post this for the next slob that runs into this problem. 只是想过,我会将其发布到遇到此问题的下一个Slob。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Android org.xmlpull.v1.XmlPullParserException错误 - Android org.xmlpull.v1.XmlPullParserException error org.xmlpull.v1.XmlPullParser出现Android ProGuard错误 - Android ProGuard error with org.xmlpull.v1.XmlPullParser Android:XmlPullParserFactory.newInstance()创建一个空工厂 - Android: XmlPullParserFactory.newInstance() creating a null factory 由 org.xmlpull.v1.XmlPullParserException 引起的错误 - Error Caused by org.xmlpull.v1.XmlPullParserException Android:XmlPullParserFactory.newInstance说找不到符号类newInstance - Android: XmlPullParserFactory.newInstance says cannot find symbol class newInstance Android-org.xmlpull.v1.XmlPullParserException:意外令牌(位置:TEXT - Android-org.xmlpull.v1.XmlPullParserException: Unexpected token (position:TEXT Android:Ksoap2 org.xmlpull.v1.XmlPullParserException - Android : Ksoap2 org.xmlpull.v1.XmlPullParserException Android org.xmlpull.v1.XmlPullParserException 解析 XML - Android org.xmlpull.v1.XmlPullParserException while parsing XML “org.xmlpull.v1.XmlPullParserException:预期:START_TAG”错误 - "org.xmlpull.v1.XmlPullParserException: expected: START_TAG" Error 在Android中调用SOAP Web服务时出现org.xmlpull.v1.XmlPullParserException - org.xmlpull.v1.XmlPullParserException while calling SOAP webservices in Android
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM