大家好,标题就是这么说的。 我正在使用asmack-android-8-4.0.6.jar。
代码是:
//1. connect to server
ConnectionConfiguration ConnectionConfiguration = new ConnectionConfiguration("gmail.com");
ConnectionConfiguration.setSecurityMode(SecurityMode.required);
ConnectionConfiguration.setDebuggerEnabled(true);
XMPPConnection connection = new XMPPTCPConnection(ConnectionConfiguration);
try { connection.connect(); report+="Connected to server\n"; }
catch (ConnectionException e){ report+=e.toString()+" - (1)\n"; }
catch (SmackException e) { report+=e.toString()+" - (2)\n"; }
catch (IOException e) { report+=e.toString()+" - (3)\n"; }
catch (XMPPException e) { report+=e.toString()+" - (4)\n"; }
tv.setText(report);
//2. login
try{ connection.login("myGmailId","MyGmailPwd"); report+="Logged in server\n";}
catch (SaslException e) { report+=e.toString()+"\n"; }
catch (XMPPException e) { report+=e.toString()+"\n"; }
catch (SmackException e) { report+=e.toString()+"\n"; }
catch (IOException e) { report+=e.toString()+"\n"; }
我无法进入第二部分,因为已经从第一部分我得到以下错误:
org.jivesoftware.smack.SmackException $ Connection Exception(1)
我还用
配置了proguard-dontnote org.xbill.DNS.spi.DNSJavaNameServiceDescriptor
-dontwarn org.xbill.DNS.spi.DNSJavaNameServiceDescriptor
# See http://stackoverflow.com/questions/5701126, happens in dnsjava
-optimizations !code/allocation/variable
# Smack specific configuration
-keep class de.measite.smack.AndroidDebugger { *; }
-keep class * implements org.jivesoftware.smack.initializer.SmackInitializer
-keep class * implements org.jivesoftware.smack.provider.IQProvider
-keep class * implements org.jivesoftware.smack.provider.PacketExtensionProvider
-keep class * extends org.jivesoftware.smack.packet.Packet
-keep class org.jivesoftware.smack.ReconnectionManager
-keep class org.jivesoftware.smackx.disco.ServiceDiscoveryManager
-keep class org.jivesoftware.smackx.xhtmlim.XHTMLManager
-keep class org.jivesoftware.smackx.muc.MultiUserChat
-keep class org.jivesoftware.smackx.bytestreams.ibb.InBandBytestreamManager
-keep class org.jivesoftware.smackx.bytestreams.socks5.Socks5BytestreamManager
-keep class org.jivesoftware.smackx.filetransfer.FileTransferManager
-keep class org.jivesoftware.smackx.iqlast.LastActivityManager
-keep class org.jivesoftware.smackx.commands.AdHocCommandManager
-keep class org.jivesoftware.smackx.ping.PingManager
-keep class org.jivesoftware.smackx.privacy.PrivacyListManager
-keep class org.jivesoftware.smackx.time.EntityTimeManager
-keep class org.jivesoftware.smackx.vcardtemp.VCardManager
-keep class org.jivesoftware.smack.CustomSmackConfiguration
欢迎任何欢迎的帮助,因为我已经卡住了一个月。 感谢名单 帕特里克
答案 0 :(得分:0)
可能会有点迟到:
首先,dnsjava lib是否正确添加到项目中? some people forget about this README
对于ConnectionException,这样的事情可能会有所帮助:
try
{
connection.connect();
}
catch (SmackException e)
{
Log.i("SmackException ", "ConnectionException: " + e.getMessage());
List<HostAddress> hostAddresses = ((SmackException.ConnectionException) e).getFailedAddresses();
if (!hostAddresses.isEmpty())
{
Log.i("SmackException: HostAddress: ", hostAddresses.get(0).toString());
Log.i("SmackException: HostAddress: ", hostAddresses.get(0).getException().toString());
}
}