2
我開發了使用Smack 4.1庫的聊天應用程序,該應用程序使用ejabberd服務器進行聊天。Xmpp String utils頻繁崩潰應用程序
所有的聊天工作正常,但有時應用程序崩潰與以下錯誤,無法理解爲什麼這經常發生?
以下錯誤從crashlytics獲得: -
Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.String.indexOf(int)' on a null object reference
at org.jxmpp.util.XmppStringUtils.parseBareJid(XmppStringUtils.java:117)
at org.jivesoftware.smack.roster.Roster$RosterPushListener.handleIQRequest(Roster.java:1386)
at org.jivesoftware.smack.AbstractXMPPConnection$2.run(AbstractXMPPConnection.java:1051)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:761)
下面的代碼用於連接和登錄到ejabberd: -
XMPPTCPConnectionConfiguration.Builder config = XMPPTCPConnectionConfiguration.builder();
config.setSecurityMode(ConnectionConfiguration.SecurityMode.disabled);
config.setServiceName(Constants.HOST);
config.setPort(Constants.PORT);
config.setHost(Constants.HOST);
config.setDebuggerEnabled(true);
config.setSendPresence(true);
config.setUsernameAndPassword(strUsername + "@" + Constants.HOST, strPassword);
SASLAuthentication.blacklistSASLMechanism("SCRAM-SHA-1");
SASLAuthentication.blacklistSASLMechanism("DIGEST-MD5");
SASLAuthentication.unBlacklistSASLMechanism("PLAIN");
objXmpptcpConnection = new XMPPTCPConnection(config.build());
objXmpptcpConnection.setUseStreamManagement(true);
objXmpptcpConnection.setUseStreamManagementResumption(true);
try {
objXmpptcpConnection.connect();
System.out.println("Connected to===>" + objXmpptcpConnection.getHost());
objXmpptcpConnection.login();
} catch (XMPPException e) {
e.printStackTrace();
} catch (SmackException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
有我錯過了它或請建議的解決方案的任何設置避免這個問題?
我沒有使用任何與roster相關的功能。那麼,有沒有任何設置可以關閉Smack的功能 –