Android 中的 XMPPConnection 错误
我使用此链接 Google 聊天
但我收到以下错误。
04-12 09:13:55.903: ERROR/AndroidRuntime(362): FATAL EXCEPTION: Thread-8
04-12 09:13:55.903: ERROR/AndroidRuntime(362): java.lang.ExceptionInInitializerError
04-12 09:13:55.903: ERROR/AndroidRuntime(362): at org.jivesoftware.smack.ConnectionConfiguration.<init>(ConnectionConfiguration.java:99)
04-12 09:13:55.903: ERROR/AndroidRuntime(362): at org.jivesoftware.smack.XMPPConnection.<init>(XMPPConnection.java:131)
04-12 09:13:55.903: ERROR/AndroidRuntime(362): at com.ex.HelloFormStuffActivity.HelloFormStuffActivity$1.run(HelloFormStuffActivity.java:38)
04-12 09:13:55.903: ERROR/AndroidRuntime(362): at java.lang.Thread.run(Thread.java:1096)
04-12 09:13:55.903: ERROR/AndroidRuntime(362): Caused by: java.lang.NoClassDefFoundError: javax.naming.directory.InitialDirContext
04-12 09:13:55.903: ERROR/AndroidRuntime(362): at org.jivesoftware.smack.util.DNSUtil.<clinit>(DNSUtil.java:50)
04-12 09:13:55.903: ERROR/AndroidRuntime(362): ... 4 more
我不知道为什么会出现这个错误。 有人可以帮助我吗?
I am using the same code from this link Google chat
But I got the below error.
04-12 09:13:55.903: ERROR/AndroidRuntime(362): FATAL EXCEPTION: Thread-8
04-12 09:13:55.903: ERROR/AndroidRuntime(362): java.lang.ExceptionInInitializerError
04-12 09:13:55.903: ERROR/AndroidRuntime(362): at org.jivesoftware.smack.ConnectionConfiguration.<init>(ConnectionConfiguration.java:99)
04-12 09:13:55.903: ERROR/AndroidRuntime(362): at org.jivesoftware.smack.XMPPConnection.<init>(XMPPConnection.java:131)
04-12 09:13:55.903: ERROR/AndroidRuntime(362): at com.ex.HelloFormStuffActivity.HelloFormStuffActivity$1.run(HelloFormStuffActivity.java:38)
04-12 09:13:55.903: ERROR/AndroidRuntime(362): at java.lang.Thread.run(Thread.java:1096)
04-12 09:13:55.903: ERROR/AndroidRuntime(362): Caused by: java.lang.NoClassDefFoundError: javax.naming.directory.InitialDirContext
04-12 09:13:55.903: ERROR/AndroidRuntime(362): at org.jivesoftware.smack.util.DNSUtil.<clinit>(DNSUtil.java:50)
04-12 09:13:55.903: ERROR/AndroidRuntime(362): ... 4 more
I have no idea why this error is coming.
Can any one help me?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
ConnectionConfiguration config = new ConnectionConfiguration("chat.facebook.com", 5222,"chat.facebook.com");
//它最终对我来说工作正常,使用asmack-2010.05.07.jar
git://gist.github.com/925250.git
ConnectionConfiguration config = new ConnectionConfiguration("chat.facebook.com", 5222,"chat.facebook.com");
//Its working fine for me finally, use asmack-2010.05.07.jar
git://gist.github.com/925250.git
在更新 eclipse 的 android 插件以及 android SDK 工具/平台工具后,我收到此错误(我的项目在更新之前工作正常)。
为了解决这个问题,我转到“属性”->“ Java 构建路径 ->订单和导出选项卡。我选中了我正在使用的 asmack jar(来自 BEEM 的那个)旁边的复选框。然后我把它移到了顶部。最初它不会工作,除非它在顶部,所以一定要尝试一下。
I got this error after I updated the android plugin for eclipse as well as the android SDK tools/platform-tools (my project worked fine before I updated).
To fix I went to Properties -> Java Build Path -> Order and Export Tab. I checked the box next to the asmack jar I am using (the one from BEEM). Then I moved it to the top. Originally it wouldn't work unless it was at the top so make sure you try that.
看来您正在使用 Ignite 的 Smack API。最初的 Smack API 旨在用于桌面使用,并使用用于 LDAP 和其他目录相关内容的 Java 命名和目录接口 (JNDI)。 Android 中不包含 JNDI,即 javax.naming 包不存在。有一个名为 asmack 的 Android 端口适合您。您只需将 Smack jar 替换为 asmack 的 jar 即可。
您可以在这里找到 asmack:https://github.com/flowdalic/asmack
It seems like you are using Ignite's Smack API. The original Smack API is intended for desktop usage and uses the Java Naming and Directory Interface (JNDI) that is used for LDAP and other directory-related stuff. JNDI is not included in Android, i.e. the package javax.naming does not exist. There is an Android port called asmack which will work for you. You simply have to replace the Smack jar by asmack's jar.
You can find asmack here: https://github.com/flowdalic/asmack