[英]I'm having trouble creating XMPP client using smack 4.2 Openfire
I want to create a simple XMPP client that connects to my Openfire server. 我想创建一个连接到Openfire服务器的简单XMPP客户端。 I got the following problem when I'm running the code.
运行代码时出现以下问题。
code: 码:
public void setConnection() {
try {
XMPPTCPConnectionConfiguration.Builder config = XMPPTCPConnectionConfiguration.builder();
config.setUsernameAndPassword(userName,password);
config.setResource("temp");
config.setXmppDomain("undercrroft");
AbstractXMPPConnection connection = new XMPPTCPConnection(config.build());
connection.connect();
} catch (InterruptedException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (SmackException e) {
e.printStackTrace();
} catch (XMPPException e) {
e.printStackTrace();
}
Error: 错误:
Information:java: Errors occurred while compiling module 'Messenger'
Information:javac 1.8.0_121 was used to compile java sources
Information:16/4/17 1:52 AM - Compilation completed with 2 errors and 0 warnings in 871ms
/home/paradox/Desktop/Project/Messenger/src/ConnectServer.java
Error:(28, 19) java: cannot access org.jxmpp.stringprep.XmppStringprepException
class file for org.jxmpp.stringprep.XmppStringprepException not found
Error:(29, 19) java: cannot access org.jxmpp.jid.DomainBareJid
class file for org.jxmpp.jid.DomainBareJid not found
These are my imports: 这些是我的进口:
import org.jivesoftware.smack.AbstractXMPPConnection;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.tcp.XMPPTCPConnection;
import org.jivesoftware.smack.tcp.XMPPTCPConnectionConfiguration;
Thanks. 谢谢。
You are missing the required jxmpp libraries. 您缺少必需的jxmpp库。 Please have a look at the Smack documentation, which lists all dependencies: https://github.com/igniterealtime/Smack/wiki/Smack-4.2-Readme-and-Upgrade-Guide#using-eclipses-android-development-tools-adt-ant-based-build
请查看Smack文档,其中列出了所有依赖项: https : //github.com/igniterealtime/Smack/wiki/Smack-4.2-Readme-and-Upgrade-Guide#using-eclipses-android-development-tools- ADT-ANT-基础的构建
Note that using a dependency manager (Gradle, Maven, Ivy) is highly recommended to prevent issues like this. 请注意,强烈建议使用依赖项管理器(Gradle,Maven,Ivy)以防止出现此类问题。
Update the Library..! 更新库..!
Those two libraries are defined in the newer library. 这两个库在较新的库中定义。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.