Android 中的 XMPPConnection 错误

发布于 2024-11-01 09:50:29 字数 1207 浏览 0 评论 0原文

我使用此链接 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

灼疼热情 2024-11-08 09:50:29

ConnectionConfiguration config = new ConnectionConfiguration("chat.facebook.com", 5222,"chat.facebook.com");

        XMPPConnection myConn = new XMPPConnection(config);
        config.setSASLAuthenticationEnabled(true);
       config.setDebuggerEnabled(true);

        try{
      myConn.connect();
//username is  no @chat.facebook.com
myConn.login("rajeshXXXXX","XXXXXXX" );




        }
        catch (Exception e) {
            System.out.println(e.toString());
        }

//它最终对我来说工作正常,使用asmack-2010.05.07.jar
git://gist.github.com/925250.git

ConnectionConfiguration config = new ConnectionConfiguration("chat.facebook.com", 5222,"chat.facebook.com");

        XMPPConnection myConn = new XMPPConnection(config);
        config.setSASLAuthenticationEnabled(true);
       config.setDebuggerEnabled(true);

        try{
      myConn.connect();
//username is  no @chat.facebook.com
myConn.login("rajeshXXXXX","XXXXXXX" );




        }
        catch (Exception e) {
            System.out.println(e.toString());
        }

//Its working fine for me finally, use asmack-2010.05.07.jar
git://gist.github.com/925250.git

因为看清所以看轻 2024-11-08 09:50:29

在更新 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.

柠檬色的秋千 2024-11-08 09:50:29

看来您正在使用 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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文