Use aSmack on Android to connect the local xmpp server and get "IllegalStateException: No DNS resolver active." -


today implement android client connect local xmpp server,when code executed following code, android app abort, please me:

public boolean login(string a, string p){         connectionconfiguration config = new connectionconfiguration("192.168.1.119");         config.setsaslauthenticationenabled(false);         config.setdebuggerenabled(false);         xmppconnection connection = new xmppconnection(config);         try{             system.out.println("hehe");             connection.connect();             connection.login(a, p);             //presence presence = new presence(presence.type.available);             //presence.setstatus("hehe");             //connection.sendpacket(presence);             return true;         }catch(xmppexception e){             e.printstacktrace();         }         return false;     } 

i got following errors:

08-09 23:30:19.091: e/androidruntime(1860): fatal exception: main 08-09 23:30:19.091: e/androidruntime(1860): java.lang.illegalstateexception: no dns resolver active. 08-09 23:30:19.091: e/androidruntime(1860):     @ org.jivesoftware.smack.util.dnsutil.resolvedomain(dnsutil.java:121) 08-09 23:30:19.091: e/androidruntime(1860):     @ org.jivesoftware.smack.util.dnsutil.resolvexmppdomain(dnsutil.java:85) 08-09 23:30:19.091: e/androidruntime(1860):     @ org.jivesoftware.smack.connectionconfiguration.<init>(connectionconfiguration.java:107) 08-09 23:30:19.091: e/androidruntime(1860):     @ com.example.chatrom.clientconserver.login(clientconserver.java:16) 08-09 23:30:19.091: e/androidruntime(1860):     @ com.example.chatrom.login$1.onclick(login.java:32) 08-09 23:30:19.091: e/androidruntime(1860):     @ android.view.view.performclick(view.java:4240) 08-09 23:30:19.091: e/androidruntime(1860):     @ android.view.view$performclick.run(view.java:17721) 08-09 23:30:19.091: e/androidruntime(1860):     @ android.os.handler.handlecallback(handler.java:730) 08-09 23:30:19.091: e/androidruntime(1860):     @ android.os.handler.dispatchmessage(handler.java:92) 08-09 23:30:19.091: e/androidruntime(1860):     @ android.os.looper.loop(looper.java:137) 08-09 23:30:19.091: e/androidruntime(1860):     @ android.app.activitythread.main(activitythread.java:5103) 08-09 23:30:19.091: e/androidruntime(1860):     @ java.lang.reflect.method.invokenative(native method) 08-09 23:30:19.091: e/androidruntime(1860):     @ java.lang.reflect.method.invoke(method.java:525) 08-09 23:30:19.091: e/androidruntime(1860):     @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:737) 08-09 23:30:19.091: e/androidruntime(1860):     @ com.android.internal.os.zygoteinit.main(zygoteinit.java:553) 08-09 23:30:19.091: e/androidruntime(1860):     @ dalvik.system.nativestart.main(native method) 

follow readme in asmack documentation , call

smackandroid.init(context) 

see flows answer here


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

.htaccess - Matching full URL in RewriteCond -