我已经包含了logcat输出。请帮我解决这个问题。
08-09 11:06:32.762:WARN / NetworkManagementSocketTagger(883): setKernelCountSet(10012,0)以errno -2
失败08-09 11:06:32.856:WARN / System.err(1567): java.security.KeyStoreException: ava.security.NoSuchAlgorithmException:KeyStore jks实现没有 结果
08-09 11:06:32.856:WARN / System.err(1567):at java.security.KeyStore.getInstance(KeyStore.java:119)
08-09 11:06:32.856:WARN / System.err(1567):at org.jivesoftware.smack.ServerTrustManager。(ServerTrustManager.java:70)
08-09 11:06:32.856:WARN / System.err(1567):at org.jivesoftware.smack.XMPPConnection.proceedTLSReceived(XMPPConnection.java:871)
08-09 11:06:32.856:WARN / System.err(1567):at org.jivesoftware.smack.PacketReader.parsePackets(PacketReader.java:221)
08-09 11:06:32.856:WARN / System.err(1567):at org.jivesoftware.smack.PacketReader.access $ 000(PacketReader.java:44)
08-09 11:06:32.856:WARN / System.err(1567):at org.jivesoftware.smack.PacketReader $ 1.run(PacketReader.java:70)
08-09 11:06:32.856:WARN / System.err(1567):引起: java.security.NoSuchAlgorithmException:KeyStore jks实现 找不到
08-09 11:06:32.856:WARN / System.err(1567):at org.apache.harmony.security.fortress.Engine.notFound(Engine.java:177)
08-09 11:06:32.856:WARN / System.err(1567):at org.apache.harmony.security.fortress.Engine.getInstance(Engine.java:151)
08-09 11:06:32.856:WARN / System.err(1567):at java.security.KeyStore.getInstance(KeyStore.java:116)
08-09 11:06:32.856:WARN / System.err(1567):... 5更多
这是添加你的代码后我现在得到的logcat消息..
08-09 11:35:34.469: WARN/System.err(1733): java.lang.NullPointerException
08-09 11:35:34.469: WARN/System.err(1733): at java.io.File.fixSlashes(File.java:185)
08-09 11:35:34.469: WARN/System.err(1733): at java.io.File.<init>(File.java:134)
08-09 11:35:34.469: WARN/System.err(1733): at java.io.FileInputStream.<init>(FileInputStream.java:105)
08-09 11:35:34.469: WARN/System.err(1733): at org.jivesoftware.smack.ServerTrustManager.<init>(ServerTrustManager.java:71)
08-09 11:35:34.469: WARN/System.err(1733): at org.jivesoftware.smack.XMPPConnection.proceedTLSReceived(XMPPConnection.java:871)
08-09 11:35:34.469: WARN/System.err(1733): at org.jivesoftware.smack.PacketReader.parsePackets(PacketReader.java:221)
08-09 11:35:34.469: WARN/System.err(1733): at org.jivesoftware.smack.PacketReader.access$000(PacketReader.java:44)
08-09 11:35:34.469: WARN/System.err(1733): at org.jivesoftware.smack.PacketReader$1.run(PacketReader.java:70)
它没有引用我的代码中的任何一行......
08-09 11:57:32.126: W/BackupManagerService(868): dataChanged but no participant pkg='com.android.providers.settings' uid=1001
08-09 11:57:32.147: W/NetworkManagementSocketTagger(868): setKernelCountSet(10012, 0) failed with errno -2
08-09 11:57:32.198: W/System.err(1497): java.lang.NullPointerException
08-09 11:57:32.198: W/System.err(1497): at java.io.File.fixSlashes(File.java:185)
08-09 11:57:32.198: W/System.err(1497): at java.io.File.<init>(File.java:134)
08-09 11:57:32.198: W/System.err(1497): at java.io.FileInputStream.<init>(FileInputStream.java:105)
08-09 11:57:32.198: W/System.err(1497): at org.jivesoftware.smack.ServerTrustManager.<init>(ServerTrustManager.java:71)
08-09 11:57:32.198: W/System.err(1497): at org.jivesoftware.smack.XMPPConnection.proceedTLSReceived(XMPPConnection.java:871)
08-09 11:57:32.198: W/System.err(1497): at org.jivesoftware.smack.PacketReader.parsePackets(PacketReader.java:221)
08-09 11:57:32.198: W/System.err(1497): at org.jivesoftware.smack.PacketReader.access$000(PacketReader.java:44)
08-09 11:57:32.198: W/System.err(1497): at org.jivesoftware.smack.PacketReader$1.run(PacketReader.java:70)
答案 0 :(得分:5)
这是我处理它的方式
ConnectionConfiguration config = new ConnectionConfiguration("your_server", port_no);
config.setSASLAuthenticationEnabled(true);
config.setCompressionEnabled(true);
config.setSecurityMode(SecurityMode.enabled);
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);
}