Smack 4.1 in android, getting exception "VerifyError" org/jivesoftware/smack/sasl/javax/SASLJavaXMechanism

This is the complete StackTrace, i saw on internet some where that Flow also faced this issue some time in 2011 using aSmack
but I’m not using aSmack. Using Smack 4.1 along with jxmpp:

Code:

XMPPTCPConnectionConfiguration.Builder connConfig = XMPPTCPConnectionConfiguration.builder();
connConfig.setSecurityMode(ConnectionConfiguration.SecurityMode.required);
connConfig.setUsernameAndPassword(USERNAME, PASSWORD);
connConfig.setServiceName(SERVICE);
connConfig.setHost(HOST);
connConfig.setPort(PORT);
connConfig.setDebuggerEnabled(true);

Exception is on this line:

XMPPTCPConnectionConfiguration.Builder connConfig = XMPPTCPConnectionConfiguration.builder();

Stack Trace:

Process: com.example.samsungchatexample, PID: 2142

java.lang.VerifyError: org/jivesoftware/smack/sasl/javax/SASLJavaXMechanism

 at org.jivesoftware.smack.sasl.javax.SASLJavaXSmackInitializer.initialize(SASLJava XSmackInitializer.java:28)

at org.jivesoftware.smack.SmackInitialization.loadSmackClass(SmackInitialization.j ava:232)

at org.jivesoftware.smack.SmackInitialization.parseClassesToLoad(SmackInitializati on.java:193)

at org.jivesoftware.smack.SmackInitialization.processConfigFile(SmackInitializatio n.java:163)

at org.jivesoftware.smack.SmackInitialization.processConfigFile(SmackInitializatio n.java:148)

 at org.jivesoftware.smack.SmackInitialization.<clinit>(SmackInitialization.java:11 6)

 at org.jivesoftware.smack.SmackConfiguration.getVersion(SmackConfiguration.java:96 )

 at org.jivesoftware.smack.ConnectionConfiguration.<clinit>(ConnectionConfiguration .java:38)

 at com.example.samsungchatexample.MainActivity$4.run(MainActivity.java:202)

at java.lang.Thread.run(Thread.java:841)

These are the jars which i have in project buildpath … am i missing something ??

You added Smack components that require a Java SE runtime which his not provided by Android. Those are all smack components with ‘java’ in its name, e.g. smack-java7, smack-resolver-javax, and so on.

Remove those, read the Smack 4.1 README. And I really recommend not adding the Smack components as .jar files to your project, as you may get problems with (transitive) dependencies. Instead use a build system which is able to fetch maven artifacts, e.g. gradle.

1 Like

Thanks Flow, I will remove all ‘java’ related jars, but i don’t know how to use build systems.
By reading the README I’ve come to realize that I have to use some XmlPullParser implementation !! sigh

Thanks again for the answer

Hi Flow,

In the smack-core jar 4.1.1 .

U people hardcode the port number so setport will not work because it take the hardcode value only 5222.

So we download the source and build it because we need to use 5280 .

because our prosody sever is running on this port.

so in this case i have to add the Smack components as .jar files.

So after that

I m getting the java.lang.VerifyError: org/jivesoftware/smack/sasl/javax/SASLJavaXMechanism

SO please tell me there is any way to resolve it.

Thanks

Hi, But If I need to rebuild SMACK for some reasons, which jars should we use? how will this error be resolved? thanx

U people hardcode the port number so setport will not work because it take the hardcode value only 5222.
Hu? Why should the port be hardcoded to 5222?

SO please tell me there is any way to resolve it.
Don’t include code that isn’t meant for Android.