2
我們正在嘗試建立連接。我們建立了連接,但是當我們嘗試登錄時,會出現大量錯誤。無法使用Android設備上的asmack 15登錄Google Talk
我們正在嘗試使用XMPPConnection對象登錄Google Talk,並將其傳遞給主機名,端口號,用戶名,密碼和資源。連接創建和設置正確,但是當我們嘗試使用創建的連接登錄Google Talk時,我們會收到很多錯誤,並且Android應用程序崩潰。
我們的代碼:
class BackgroundConnection extends AsyncTask<String, Void, XMPPConnection> {
@Override
protected XMPPConnection doInBackground(String... arg0) {
String host = "talk.google.com"; //getText(R.id.host); //"talk.google.com"
String port = "5222"; //getText(R.id.port); //"5222"
String service = "gmail.com"; //getText(R.id.service); //"gmail.com"
String username = "[email protected]"; //getText(R.id.userid);
String password = "password"; //getText(R.id.password);
String resource = "web"; //"smack"
// Create a connection
ConnectionConfiguration connConfig =
new ConnectionConfiguration(host, 5222, service);
//connConfig.setLoginInfo(username, password, resource);
XMPPConnection connection = new XMPPConnection(connConfig);
try {
connection.connect();
Log.i("XMPPClient", "[SettingsDialog] Connected to " + connection.getHost());
} catch (Exception ex) {
Log.e("XMPPClient", "[SettingsDialog] Failed to connect to " + connection.getHost());
Log.e("XMPPClient", ex.toString());
xmppClient.setConnection(null);
}
try {
// ***FAILS HERE***
connection.login(username, password, resource);
Log.i("XMPPClient", "Logged in as " + connection.getUser());
// Set the status to available
Presence presence = new Presence(Presence.Type.available);
connection.sendPacket(presence);
xmppClient.setConnection(connection);
} catch (Exception ex) {
Log.e("ERROR","Failed to login: " + ex.toString());
Log.e("XMPPClient", "[SettingsDialog] Failed to log in as " + username);
Log.e("XMPPClient", ex.toString());
xmppClient.setConnection(null);
}
return null;
}
}
錯誤:
11-11 13:17:35.829: I/XMPPClient(6075): [SettingsDialog] Connected to talk.google.com
11-11 13:17:40.534: I/dalvikvm(6075): Could not find method javax.security.sasl.SaslClient.hasInitialResponse, referenced from method org.jivesoftware.smack.sasl.SASLMechanism.authenticate
11-11 13:17:40.534: W/dalvikvm(6075): VFY: unable to resolve interface method 3710: Ljavax/security/sasl/SaslClient;.hasInitialResponse()Z
11-11 13:17:40.534: D/dalvikvm(6075): VFY: replacing opcode 0x72 at 0x0003
11-11 13:17:40.534: W/dalvikvm(6075): VFY: unable to resolve exception class 680 (Ljavax/security/sasl/SaslException;)
11-11 13:17:40.534: W/dalvikvm(6075): VFY: unable to find exception handler at addr 0x29
11-11 13:17:40.544: W/dalvikvm(6075): VFY: rejected Lorg/jivesoftware/smack/sasl/SASLMechanism;.authenticate()V
11-11 13:17:40.544: W/dalvikvm(6075): VFY: rejecting opcode 0x0d at 0x0029
11-11 13:17:40.544: W/dalvikvm(6075): VFY: rejected Lorg/jivesoftware/smack/sasl/SASLMechanism;.authenticate()V
11-11 13:17:40.544: W/dalvikvm(6075): Verifier rejected class Lorg/jivesoftware/smack/sasl/SASLMechanism;
11-11 13:17:40.544: W/dalvikvm(6075): Class init failed in Constructor.constructNative (Lorg/jivesoftware/smack/sasl/SASLPlainMechanism;)
11-11 13:17:55.680: W/System.err(6075): java.io.EOFException: no more data available - expected end tag </stream:stream> to close start tag <stream:stream> from line 1, parser stopped on END_TAG seen ...</mechanisms></stream:features>... @1:335
11-11 13:17:55.680: W/System.err(6075): at org.xmlpull.mxp1.MXParser.fillBuf(MXParser.java:3035)
11-11 13:17:55.690: W/System.err(6075): at org.xmlpull.mxp1.MXParser.more(MXParser.java:3046)
11-11 13:17:55.690: W/System.err(6075): at org.xmlpull.mxp1.MXParser.nextImpl(MXParser.java:1144)
11-11 13:17:55.730: W/System.err(6075): at org.xmlpull.mxp1.MXParser.next(MXParser.java:1093)
11-11 13:17:55.730: W/System.err(6075): at org.jivesoftware.smack.PacketReader.parsePackets(PacketReader.java:325)
11-11 13:17:55.730: W/System.err(6075): at org.jivesoftware.smack.PacketReader.access$000(PacketReader.java:43)
11-11 13:17:55.730: W/System.err(6075): at org.jivesoftware.smack.PacketReader$1.run(PacketReader.java:70)
11-11 13:18:49.928: W/dalvikvm(6075): threadid=11: thread exiting with uncaught exception (group=0x40c63a68)
11-11 13:18:49.988: E/AndroidRuntime(6075): FATAL EXCEPTION: AsyncTask #1
11-11 13:18:49.988: E/AndroidRuntime(6075): java.lang.RuntimeException: An error occured while executing doInBackground()
11-11 13:18:49.988: E/AndroidRuntime(6075): at android.os.AsyncTask$3.done(AsyncTask.java:278)
11-11 13:18:49.988: E/AndroidRuntime(6075): at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
11-11 13:18:49.988: E/AndroidRuntime(6075): at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
11-11 13:18:49.988: E/AndroidRuntime(6075): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
11-11 13:18:49.988: E/AndroidRuntime(6075): at java.util.concurrent.FutureTask.run(FutureTask.java:137)
11-11 13:18:49.988: E/AndroidRuntime(6075): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:208)
11-11 13:18:49.988: E/AndroidRuntime(6075): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
11-11 13:18:49.988: E/AndroidRuntime(6075): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
11-11 13:18:49.988: E/AndroidRuntime(6075): at java.lang.Thread.run(Thread.java:856)
11-11 13:18:49.988: E/AndroidRuntime(6075): Caused by: java.lang.VerifyError: org/jivesoftware/smack/sasl/SASLMechanism
11-11 13:18:49.988: E/AndroidRuntime(6075): at java.lang.reflect.Constructor.constructNative(Native Method)
11-11 13:18:49.988: E/AndroidRuntime(6075): at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
11-11 13:18:49.988: E/AndroidRuntime(6075): at org.jivesoftware.smack.SASLAuthentication.authenticate(SASLAuthentication.java:315)
11-11 13:18:49.988: E/AndroidRuntime(6075): at org.jivesoftware.smack.XMPPConnection.login(XMPPConnection.java:203)
11-11 13:18:49.988: E/AndroidRuntime(6075): at com.hemelix.xmppClient.SettingsDialog$BackgroundConnection.doInBackground(SettingsDialog.java:108)
11-11 13:18:49.988: E/AndroidRuntime(6075): at com.hemelix.xmppClient.SettingsDialog$BackgroundConnection.doInBackground(SettingsDialog.java:1)
11-11 13:18:49.988: E/AndroidRuntime(6075): at android.os.AsyncTask$2.call(AsyncTask.java:264)
11-11 13:18:49.988: E/AndroidRuntime(6075): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
11-11 13:18:49.988: E/AndroidRuntime(6075): ... 5 more
11-11 13:24:00.369: I/Process(6075): Sending signal. PID: 6075 SIG: 9
什麼是錯的任何想法?