无法在android中的xmpp服务器中连接

时间:2014-11-06 07:08:06

标签: android xmpp smack

我正在使用Samck 4.1.0-alpha库来创建Xmpp客户端。我创建了有效的用户。我试图通过代码发送消息。但得到错误。 代码:

new Runnable(){

            @Override
            public void run() {
                // TODO Auto-generated method stub
                ConnectionConfiguration config = new ConnectionConfiguration("jabb3r.org", 5222, "jabb3r.org");
                XMPPConnection connection = new XMPPTCPConnection(config);
                try {
                    connection.connect();
                    connection.login("USERNAME", "PASSWORD");
                    // Assume we've created a XMPPConnection name "connection"._
                    ChatManager chatmanager = ChatManager.getInstanceFor(connection);
                    Chat newChat = chatmanager.createChat("neilneil@jabb3r.org", new MessageListener() {
                        public void processMessage(Chat chat, Message message) {
                            System.out.println("Received message: " + message);
                        }
                    });

                    try {
                        newChat.sendMessage("Howdy!");
                    }
                    catch (XMPPException e) {
                        System.out.println("Error Delivering block");
                    }
//                  ConnectionException.getFailedAddresses();
                } catch (SmackException | IOException | XMPPException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }

        };

我收到这个奇怪的错误。 日志:

11-06 06:55:47.913: E/AndroidRuntime(1604): FATAL EXCEPTION: Thread-115
11-06 06:55:47.913:E/AndroidRuntime(1604):java.lang.NoClassDefFoundError:org.xbill.DNS.ResolverConfig
11-06 06:55:47.913: E/AndroidRuntime(1604):     at org.jivesoftware.smack.SmackAndroid$1$1.run(SmackAndroid.java:41)

我找不到调试此错误的资源。

1 个答案:

答案 0 :(得分:6)

https://community.igniterealtime.org/thread/49329

  

(请务必阅读自述文件,否则无效!)

https://github.com/Flowdalic/asmack/blob/master/README.asmack

Smack requires dnsjava for DNS SRV record lookup. You need to add the
dnsjava library to your project's libraries.

http://www.dnsjava.org/download/