2

接続を確立しようとしています。接続は確立されますが、ログインしようとすると、多数のエラーが発生します。

XMPPConnection オブジェクトを使用して Google トークにログインしようとしており、それにホスト名、ポート番号、ユーザー名、パスワード、およびリソースへの参照を渡しています。接続が作成され、適切に設定されていますが、作成された接続を使用して Google トークにログインしようとすると、多くのエラーが発生し、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 = "username@gmail.com"; //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

何が間違っているかについてのアイデアはありますか?

4

1 に答える 1

0

SSLトラストストアタイプをbksに変更する必要があります。(Facebook接続を無視し、bksのものを気にします)。

参照:setConnection

于 2013-01-31T10:11:58.410 に答える