【发布时间】:2014-12-29 14:45:59
【问题描述】:
大家好,标题说明了一切。 我正在使用 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$连接异常(一)
我也配置了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
由于我被困一个月以来,请提供任何帮助。 谢谢 妙招
【问题讨论】:
-
您好,欢迎来到 StackOverflow!。只是倾倒大量代码并要求“给我答案”并不是很有建设性。当您尝试解释您要完成的工作以及遇到的问题时,您可能会得到更好的答案。
-
好吧抱歉,我以为我已经说清楚了。我正在尝试使用 eclipse IDE 和 asmack-android-8-4.0.6.jar 在 android 上进行非常基本的聊天。我想连接到 gmail 服务器。我使用上面的代码,但我得到了上面描述的错误。我还能说什么?
-
你可以用谷歌搜索“Smack ConnectionException”
-
感谢您的提示。从谷歌搜索我看到我必须添加以下行: Context context = getApplicationContext(); SmackAndroid.init(上下文);但是当我执行程序崩溃并在 logcat 中出现错误时:“找不到从方法 org.jivesoftware.util.dns.dnsjava.DNSJavaResolver.lookupSRVRecord 引用的类 'org.xbill.dns.lookup。请提供其他帮助吗?