想使用最新的Smack4.1.0 在我的项目当中,就先搞一个单独的,希望能跑起来。结果就是简单的都弄不起来。导入所有包后,可以编译通过。
但是一使用到它的包,就抛个异常给我。整了半天也没弄明白是包的原因还是哪配置的问题。
在网上找到这个资料:https://github.com/igniterealtime/Smack/wiki/Smack-4.1-Readme-and-Upgrade-Guide
也不会弄,又是phython又是maven又是Ant的,英语也不好,不知道怎么弄。
有用过的大神能使用的吗?求源码!!!
这是我的代码,就是按官方介绍打出来的:
public void onClick(View v){
new Thread(new Runnable() {
@Override
public void run() {
try {
XMPPTCPConnection connection = getConnection();
connection.connect();
connection.login("anytime_eeeeee","qq123456","ubuntu");
} catch (SmackException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (XMPPException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
}
}).start();
}
private XMPPTCPConnection getConnection(){
XMPPTCPConnectionConfiguration.Builder builder = XMPPTCPConnectionConfiguration.builder();
builder.setServiceName("ubuntu");
builder.setHost("58.64.162.184");
builder.setPort(5222);
builder.setCompressionEnabled(false);
builder.setDebuggerEnabled(false);
builder.setSendPresence(true);
builder.setSecurityMode(ConnectionConfiguration.SecurityMode.disabled);
XMPPTCPConnection connection = new XMPPTCPConnection(builder.build());
return connection;
}