Android的4.1嫌与问题连接 [英] Android smack 4.1 issue with connection

查看:296
本文介绍了Android的4.1嫌与问题连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图与 GoogleTalk测试在Android中使用的连接。
我跟着在互联网上大量的教程实例,但仍我似乎无法使它发挥作用。

I'm trying to make a connection with GoogleTalk in android using Smack. I've followed numerous tutorials examples on the internet yet still I can't seem to make it work.

public static final String HOST = "talk.google.com";

public static final int PORT = 5222;
public static final String SERVICE = "gmail.com";
public static final String USERNAME = "myemail@gmail.com";
public static final String PASSWORD = "mypassword";

我上面的凭据是正确的...

My above credentials are correct...

 XMPPTCPConnectionConfiguration.Builder connConfig = XMPPTCPConnectionConfiguration.builder();
   connConfig.setSecurityMode(ConnectionConfiguration.SecurityMode.required);
   connConfig.setUsernameAndPassword(USERNAME, PASSWORD);
   connConfig.setServiceName(SERVICE);
   connConfig.setHost(HOST);
   connConfig.setPort(PORT);
   connConfig.setDebuggerEnabled(true);
   //setCompressionEnabled(false).build();
   //(HOST, PORT, SERVICE);
   XMPPTCPConnection connection = new  XMPPTCPConnection(connConfig.build());
     try {
       connection.connect();
       Log.i("XMPPChatDemoActivity",  "[SettingsDialog] Connected to "+connection.getHost());
     } catch (XMPPException ex) {
         Log.e("XMPPChatDemoActivity",  "[SettingsDialog] Failed to connect to "+ connection.getHost());
         Log.e("XMPPChatDemoActivity", ex.toString());
         setConnection(null);
     }
     catch(SmackException ex){
         Log.e("XMPPChatDemoActivity",  "[SettingsDialog] Failed to connect to "+ connection.getHost());
         Log.e("XMPPChatDemoActivity", ex.toString());
         setConnection(null);
     }
     catch(IOException ex){
         Log.e("XMPPChatDemoActivity",  "[SettingsDialog] Failed to connect to "+ connection.getHost());
         Log.e("XMPPChatDemoActivity", ex.toString());
         setConnection(null);
     }

我得到 java.lang.ExceptionInInitializeError

在此行

XMPPTCPConnectionConfiguration.Builder connConfig = XMPPTCPConnectionConfiguration.builder(); //行184

下面是完整的堆栈跟踪:

Here is the complete stack trace:

 FATAL EXCEPTION: Thread-120
java.lang.ExceptionInInitializerError
at com.example.samsungchatexample.MainActivity$4.run(MainActivity.java:184)
at java.lang.Thread.run(Thread.java:856)
Caused by: java.lang.ExceptionInInitializerError
at org.jivesoftware.smack.SmackConfiguration.getVersion(SmackConfiguration.java:96)
at org.jivesoftware.smack.ConnectionConfiguration.<clinit>(ConnectionConfiguration.java:38)

Caused by: java.lang.ExceptionInInitializerError
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:217)
at org.jivesoftware.smack.SmackInitialization.loadSmackClass(SmackInitialization.java:213)
at org.jivesoftware.smack.SmackInitialization.parseClassesToLoad(SmackInitialization.java:193)
at org.jivesoftware.smack.SmackInitialization.processConfigFile(SmackInitialization.java:163)
at org.jivesoftware.smack.SmackInitialization.processConfigFile(SmackInitialization.java:148)
at org.jivesoftware.smack.SmackInitialization.<clinit>(SmackInitialization.java:116)

Caused by: java.lang.NoClassDefFoundError: javax.naming.directory.InitialDirContext
at org.jivesoftware.smack.util.dns.javax.JavaxResolver.<clinit>(JavaxResolver.java:50)

有人可以帮助我?我已经在奇巧试用了软糖
在两个相同的异常,所以这是不是与上下文的操作系统版本毛刺。我缺少什么?

Can someone please help me with this ? I've tested this on KitKat and JellyBean Same exception on both so this is not a glitch with context to OS versions. What am I missing ?

推荐答案

我做脸的问题,同时建立使用SMACK 4.1的连接。
当我包括以下所有然后提到的这些图书馆我成功地建立了连接。试试看吧:)希望你成功。

I do face problem while establishing a connection using SMACK 4.1. When I included all of these libraries mentioned below then I successfully established a connection. Give it a try :) Hope you succeed.


  1. jxmpp核-0.4.1

  2. jxmpp-UTIL缓存-0.4.1

  3. minidns-0.1.1

  4. 嫌-Android的4.1.0.jar

  5. 嫌-Android的扩展-4.1.0

  6. 嫌核心-4.1.0

  7. 咂嘴的扩展-4.1.0

  8. 嫌-IM-4.1.0

  9. 嫌-TCP-4.1.0

这篇关于Android的4.1嫌与问题连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆