android - Getting error with SmackAndroid.init(context) -
i trying create room using asmack muc. have connect() method connects xmpp server no problem (below). public void connect() { connectionconfiguration connconfig = new connectionconfiguration(host, port, service); xmppconnection connection = new xmppconnection(connconfig); try { connection.connect(); log.i("xmppchatdemoactivity", "connected " + connection.gethost()); } catch (xmppexception ex) { log.e("xmppchatdemoactivity", "failed connect " + connection.gethost()); log.e("xmppchatdemoactivity", ex.tostring()); setconnection(null); } try { connection.login(username, password); log.i("xmppchatdemoactivity", "logged in " + connection.getuser()); presence presence = new presence(presence.type.available); connection.sendpacket(presence); setconnection(connection); } catch (xmppexception ex) { log.e("xmppchatdemoactivity", "failed log in " + username); log.e("xmppchatdemoactivity", ex.tostring()); setconnection(null); } } when try use .create function in createroom method below: private void createroom() { multiuserchat muc = new multiuserchat(connection, "name@conference.<myxmppserver>"); try { if (connection != null) { muc.create("testroom"); form form = muc.getconfigurationform(); form submitform = form.createanswerform(); (iterator fields = form.getfields(); fields.hasnext();) { formfield field = (formfield) fields.next(); if (!formfield.type_hidden.equals(field.gettype()) && field.getvariable() != null) { submitform.setdefaultanswer(field.getvariable()); } } submitform.setanswer("muc#roomconfig_publicroom", true); muc.sendconfigurationform(submitform); } } catch (exception e) { e.printstacktrace(); } }
it gives me classcastexception error, solution here: classcastexception when creating muc room xmpp group chat using asmack
however when add
context context = getapplicationcontext(); smackandroid.init(context);
to beginning of connect() method, getting error:
java.lang.noclassdeffounderror: org.jivesoftware.smack.smackandroid
but have added asmack library containing class smackandroid build path in eclipse. not sure how solve problem since class seems in build path @ compile time, isn't found @ runtime. suggestions? thank you!
in response question:
java.lang.noclassdeffounderror: org.jivesoftware.smack.smackandroid
but have added asmack library containing class smackandroid build path in eclipse. not sure how solve problem since class seems in build path @ compile time, isn't found @ runtime. suggestions? thank you!
have tried setting asmack library under properties > java build path > order , export menus? (not libraries tab) seems compile without error then.
Comments
Post a Comment