0

Hello everyone the title says it all. I'm using asmack-android-8-4.0.6.jar.

The code is:

 //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"; }

I can't get to the second part since already from the first part I get the following error:

org.jivesoftware.smack.SmackException$Connection Exception (1)

I have also configured proguard with

-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

please please any help in welcome since I'm stuck since a month. thanx PAtrick

Patrick
  • 3,073
  • 2
  • 22
  • 60
  • 2
    Hello and welcome to StackOverflow!. Just dumping a lot of code and asking 'give me the answer' is not very constructive. You may get better answers when you try to explain what you are trying to accomplish, and what problem you have run into. – oɔɯǝɹ Dec 29 '14 at 14:52
  • Ok sorry I thought I had made it clear. I am trying to make a very basic chat on android with the eclipse IDE and asmack-android-8-4.0.6.jar. I'd like to connect to the gmail server. I use the above code but I get the error described above. What else can I say? – Patrick Dec 29 '14 at 15:11
  • You could have googled for "Smack ConnectionException" – Flow Dec 29 '14 at 18:49
  • possible duplicate of [ConnectionException when trying to connect to Openfire XMPP server from aSmack Android client](http://stackoverflow.com/questions/25998575/connectionexception-when-trying-to-connect-to-openfire-xmpp-server-from-asmack-a) – Flow Dec 29 '14 at 18:49
  • Thanx for the hints. From googling I've seen that I have to add the lines: Context context = getApplicationContext(); SmackAndroid.init(context); but when I do the program crashes and in logcat I get the error: "could not find class 'org.xbill.dns.lookup referenced from method org.jivesoftware.util.dns.dnsjava.DNSJavaResolver.lookupSRVRecord. Please any additional help? – Patrick Dec 30 '14 at 12:59

1 Answers1

0

Might be a little late:

First of all, is the dnsjava lib added correctly to the project? some people forget about this README.

For the ConnectionException maybe something like this will help:

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());
     }

}

TommySM
  • 3,793
  • 3
  • 24
  • 36
  • Thank you for your help and sorry for being late in answering myself. I added dnsjava-2.1.6.jar in the libs folder. The problem is that I can't even get to get information from the code above. This is because i've seen that to work properly BEFORE I have to put Context context = getApplicationContext(); SmackAndroid.init(context); but if I do that the program crashes! Am I the only one in the world who is not able to make a SIMPLE chat work?!? :-( – Patrick Jan 27 '15 at 12:49
  • could you give some more info? maybe edit your question and add the code snipet with the Context and SmackAndroid.init() part? – TommySM Feb 01 '15 at 16:02