pan
1
Hello there,
I met some problems when I tryed to use smack4.1.3 on Android application,
When I run android application ,logout tellls like “java.lang.VerifyError…”
I have tryed several ways which found on the Internet ,but those did not work for my case.
Tools…ADT,SDK4.3 and JDK1.7 ,I use complier1.6 because of sdk’s version,does it OK?
Error Information
VFY:unable to find exception handler at addr 0x16
VFY:rejected Lcom/example/smackTest3/smackClientFunction…
FATAL EXCEPTION :main
java.lang.VerifyError:com/example/smackTest3/smack/SmackClientFunction at …MainActivity.onCreate(java:17)
at android.app Activity.performCreate(Activity.java:5133)
…
…
at dalvik.system.NativeStart.main(Native method)
Hope your reply
Thank you~
pan
3
package com.can.smack4_1; import java.io.IOException; import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.tcp.XMPPTCPConnection;
import org.jivesoftware.smack.tcp.XMPPTCPConnectionConfiguration;
import org.jivesoftware.smack.ConnectionConfiguration; import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View; public class MainActivity extends Activity { @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); }
public void onClick(View v){
new Thread(new Runnable() { @Override
public void run() {
try {
XMPPTCPConnection connection = getConnection();
connection.connect();
connection.login("test","test","ubuntu");
} catch (SmackException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (XMPPException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
}
}).start();
}
private XMPPTCPConnection getConnection(){ XMPPTCPConnectionConfiguration.Builder builder = XMPPTCPConnectionConfiguration.builder();
// builder.setServiceName("ubuntu");
builder.setHost("58.64.162.184");
builder.setPort(5222);
builder.setCompressionEnabled(false);
builder.setDebuggerEnabled(false);
builder.setSendPresence(true);
builder.setSecurityMode(ConnectionConfiguration.SecurityMode.disabled); XMPPTCPConnection connection = new XMPPTCPConnection(builder.build());
return connection;
} @Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
} @Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
pan
4
These are jars of my proj