我真的被这个错误困住了,我不知道如何解决它。我正在尝试连接到 XMMP 服务器,我可以连接并且用户可以发送和接收消息,但是我收到一个错误:java.io.FileNotFoundException: /system/lib/security/cacerts: open failed: ENOENT (No such文件或目录)
代码是:
public void startChat(String buddyLogin) {
this.friendLogin = buddyLogin;
TAG = "ChatService.startChat";
SmackAndroid.init(ctx);
new Thread(new Runnable() {
@Override
public void run() {
XMPPConnection.DEBUG_ENABLED = true;
Connection.DEBUG_ENABLED = true;
Log.d(TAG, "CHAT_SERVER "+CHAT_SERVER);
try {
config = new AndroidConnectionConfiguration(CHAT_SERVER);
SASLAuthentication.supportSASLMechanism("PLAIN");
config.setSASLAuthenticationEnabled(true);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
config.setTruststoreType("AndroidCAStore");
config.setTruststorePassword(null);
// config.setTruststorePath(null);
} else {
config.setTruststoreType("BKS");
/* String path = System.getProperty("javax.net.ssl.trustStore");
if (path == null)
path = System.getProperty("java.home") + File.separator + "etc"
+ File.separator + "security" + File.separator
+ "cacerts.bks";
config.setTruststorePath(path);*/
}
connection = new XMPPConnection(config);
connection.connect();
connection.login(chatLogin, QuickBloxUtils.password);
chatManager = connection.getChatManager();
chat = chatManager.createChat(friendLogin, messageListener);
chatManager.addChatListener(chatManagerListener);
} catch (XMPPException e) {
Log.e(TAG, "Error al intentar conectar.", e);
}
}
}).start();
}
我只是想知道错误是因为它没有找到 struststoretype。但我不知道如何解决它。有什么帮助吗?