Android:QuickBox chatService.login失败

Android:QuickBox chatService.login失败,android,messaging,instant,Android,Messaging,Instant,我正在尝试使用QuickBox在我的应用程序中建立IM,并在一个新项目中进行测试,但似乎从未触发登录onSuccess和onError。会话已创建,但登录失败(但未返回任何错误),onSuccess和onError中的Toast都不会到达 QBSettings.getInstance().init(getApplicationContext(), APP_ID, AUTH_KEY, AUTH_SECRET); QBSettings.getInstance().setAccountKey(

我正在尝试使用QuickBox在我的应用程序中建立IM,并在一个新项目中进行测试,但似乎从未触发登录onSuccess和onError。会话已创建,但登录失败(但未返回任何错误),onSuccess和onError中的Toast都不会到达

QBSettings.getInstance().init(getApplicationContext(), APP_ID, AUTH_KEY, AUTH_SECRET);
    QBSettings.getInstance().setAccountKey(ACCOUNT_KEY);
    try {
        QBAuth.getBaseService().setToken("bede1c97d992755ba5ceae43b76ded687c71a1c2");
    } catch (BaseServiceException e) {
        e.printStackTrace();
    }
    QBChatService.setDebugEnabled(true); 
    QBChatService.setDefaultConnectionTimeout(60);
    final QBChatService chatService = QBChatService.getInstance();
    final QBUser user = new QBUser("roudy", "kanaan123");
    QBAuth.createSession(user, new QBEntityCallback<QBSession>() {
        @Override
        public void onSuccess(final QBSession session, Bundle params) {
            Toast.makeText(MainActivity.this, "Session Created", Toast.LENGTH_SHORT).show();
            user.setId(1);
            chatService.login(user, new QBEntityCallback() { // also tried QBChatService.getInstance().login

                @Override
                public void onSuccess(Object o, Bundle bundle) {
                    Toast.makeText(MainActivity.this, "user logged in", Toast.LENGTH_SHORT).show();
                    privateChatManager = chatService.getPrivateChatManager();
                    privateChatManager.createDialog(2, new QBEntityCallback<QBDialog>() {
                        @Override
                        public void onSuccess(QBDialog dialog, Bundle args) {
                            Toast.makeText(getBaseContext(), "dialog created", Toast.LENGTH_LONG).show();
                        }

                        @Override
                        public void onError(QBResponseException errors) {
                            Toast.makeText(getBaseContext(), errors.toString(), Toast.LENGTH_LONG).show();
                        }
                    });

                    privateChatMessageListener = new QBMessageListener<QBPrivateChat>() {
                        @Override
                        public void processMessage(QBPrivateChat privateChat, final QBChatMessage chatMessage) {

                        }

                        @Override
                        public void processError(QBPrivateChat privateChat, QBChatException error, QBChatMessage originMessage) {

                        }
                    };

                    privateChatManagerListener = new QBPrivateChatManagerListener() {
                        @Override
                        public void chatCreated(final QBPrivateChat privateChat, final boolean createdLocally) {
                            if (!createdLocally) {
                                privateChat.addMessageListener(privateChatMessageListener);
                            }
                        }
                    };
                    QBChatService.getInstance().getPrivateChatManager().addPrivateChatManagerListener(privateChatManagerListener);

                }

                @Override
                public void onError(QBResponseException e) {
                    Toast.makeText(MainActivity.this, e.toString(), Toast.LENGTH_SHORT).show();
                }
            });

        }

        @Override
        public void onError(QBResponseException errors) {
            Toast.makeText(MainActivity.this, errors.toString(), Toast.LENGTH_SHORT).show();
        }
    });
QBSettings.getInstance().init(getApplicationContext(),APP\u ID,AUTH\u KEY,AUTH\u SECRET);
QBSettings.getInstance().setAccountKey(帐户密钥);
试一试{
setToken(“bede1c97d992755ba5ceae43b76ded687c71a1c2”);
}捕获(BaseServiceException e){
e、 printStackTrace();
}
QBChatService.setDebugEnabled(true);
QBChatService.setDefaultConnectionTimeout(60);
final QBChatService chatService=QBChatService.getInstance();
最终QBUser用户=新QBUser(“roudy”、“kanaan123”);
createSession(用户,新的QBEntityCallback(){
@凌驾
成功时公共无效(最终QBSession会话,捆绑参数){
Toast.makeText(MainActivity.this,“会话已创建”,Toast.LENGTH_SHORT.show();
user.setId(1);
chatService.login(用户,新的QBEntityCallback(){//还尝试了QBChatService.getInstance().login
@凌驾
成功时的公共void(对象o,Bundle){
Toast.makeText(MainActivity.this,“用户登录”,Toast.LENGTH_SHORT.show();
privateChatManager=chatService.getPrivateChatManager();
createDialog(2,新的QBEntityCallback(){
@凌驾
成功时公共无效(QB对话框,捆绑参数){
Toast.makeText(getBaseContext(),“对话框已创建”,Toast.LENGTH_LONG.show();
}
@凌驾
公共无效onError(QBResponseException错误){
Toast.makeText(getBaseContext(),errors.toString(),Toast.LENGTH_LONG).show();
}
});
privateChatMessageListener=新的QBMessageListener(){
@凌驾
public void processMessage(QBPrivateChat privateChat,最终QBChatMessage chatMessage){
}
@凌驾
public void processError(QBPrivateChat privateChat、QBChatException错误、QBChatMessage originMessage){
}
};
privateChatManagerListener=新的QBPrivateChatManagerListener(){
@凌驾
已创建公共无效聊天室(最终QBPrivateChat privateChat,最终布尔值createdLocally){
如果(!createdLocally){
addMessageListener(privateChatMessageListener);
}
}
};
QBChatService.getInstance().getPrivateChatManager().addPrivateChatManagerListener(privateChatManagerListener);
}
@凌驾
公共无效报告人(QBResponseException e){
Toast.makeText(MainActivity.this,e.toString(),Toast.LENGTH_SHORT).show();
}
});
}
@凌驾
公共无效onError(QBResponseException错误){
Toast.makeText(MainActivity.this,errors.toString(),Toast.LENGTH_SHORT.show();
}
});
我可以在run/android监视器日志中看到:

    07-28 09:21:54.107 16144-16184/com.example.roudy.quickboxtest D/QBASDK: Connecting to chat: chat.quickblox.com
07-28 09:21:54.143 16144-16167/com.example.roudy.quickboxtest W/EGL_emulation: eglSurfaceAttrib not implemented
07-28 09:21:54.143 16144-16167/com.example.roudy.quickboxtest W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0xa346ec20, error=EGL_SUCCESS
07-28 09:21:54.158 16144-16167/com.example.roudy.quickboxtest V/RenderScript: 0xae9b0800 Launching thread(s), CPUs 4
07-28 09:21:54.466 16144-16198/com.example.roudy.quickboxtest D/SMACK: SENT (0): <stream:stream xmlns='jabber:client' to='chat.quickblox.com' xmlns:stream='http://etherx.jabber.org/streams' version='1.0' xml:lang='en'>
07-28 09:21:54.661 16144-16199/com.example.roudy.quickboxtest D/SMACK: RECV (0): <?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' from='chat.quickblox.com' id='ea0fa35d-e7e1-46d9-88ea-eefab4fd8dbb' version='1.0' xml:lang='en'>
07-28 09:21:54.853 16144-16199/com.example.roudy.quickboxtest D/SMACK: RECV (0): <stream:features><sm xmlns="urn:xmpp:sm:3"/><mechanisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl"><mechanism>PLAIN</mechanism><mechanism>ANONYMOUS</mechanism></mechanisms><ver xmlns="urn:xmpp:features:rosterver"/><starttls xmlns="urn:ietf:params:xml:ns:xmpp-tls"/><compression xmlns="http://jabber.org/features/compress"><method>zlib</method></compression></stream:features>
07-28 09:23:54.659 16144-16199/com.example.roudy.quickboxtest D/SMACK: RECV (0): </stream:stream>
07-28 09:23:54.660 16144-16198/com.example.roudy.quickboxtest D/SMACK: SENT (0): <presence id='rm2kQ-1' type='unavailable'></presence>
07-28 09:23:54.660 16144-16198/com.example.roudy.quickboxtest D/SMACK: SENT (0): </stream:stream>
07-28 09:21:54.107 16144-16184/com.example.roudy.quickboxtest D/QBASDK:连接聊天室:chat.quickblox.com
07-28 09:21:54.143 16144-16167/com.example.roudy.quickboxtest W/EGL_仿真:未实现eglSurfaceAttrib
07-28 09:21:54.143 16144-16167/com.example.roudy.quickboxtest W/OpenGLRenderer:未能在表面0xa346ec20上设置EGL_交换_行为,错误=EGL_成功
07-28 09:21:54.158 16144-16167/com.example.roudy.quickboxtest V/RenderScript:0xae9b0800启动线程,CPU 4
07-28 09:21:54.466 16144-16198/com.example.roudy.quickboxtest D/SMACK:SENT(0):
07-28 09:21:54.661 16144-16199/com.example.roudy.quickboxtest D/SMACK:RECV(0):
07-28 09:21:54.853 16144-16199/com.example.roudy.quickboxtest D/SMACK:RECV(0):PLAINANONYMOUSzlib
07-28 09:23:54.659 16144-16199/com.example.roudy.quickboxtest D/SMACK:RECV(0):
07-28 09:23:54.660 16144-16198/com.example.roudy.quickboxtest D/SMACK:SENT(0):
07-28 09:23:54.660 16144-16198/com.example.roudy.quickboxtest D/SMACK:SENT(0):
编辑:我现在似乎在emulator中遇到了一个不同的错误(我在createSession之前注销了一次,从那时起我就收到了这个错误):

07-28 09:45:28.647 5679-5735/com.example.roudy.quickboxtest D/QBASDK:已连接。登录聊天室,当前用户JID:15681103-44582,资源:android_9d191aed08b8ec31
07-28 09:45:28.648 5679-5749/com.example.roudy.quickboxtest D/SMACK:SENT(0):ADE1NjgxMTAzLTQ0NTgyAGthbmFhbjEyMw==
07-28 09:45:28.835 5679-5750/com.example.roudy.quickboxtest D/SMACK:RECV(0):
固定的:

事实证明你不能在主线程中登录,我创建了一个实现Runnable的独立类,并在onCreate中运行它,它工作得非常好

07-28 09:45:28.647 5679-5735/com.example.roudy.quickboxtest D/QBASDK: Connected. Login to chat, currentUser JID: 15681103-44582, resource: android_9d191aed08b8ec31
07-28 09:45:28.648 5679-5749/com.example.roudy.quickboxtest D/SMACK: SENT (0): <auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='PLAIN'>ADE1NjgxMTAzLTQ0NTgyAGthbmFhbjEyMw==</auth>
07-28 09:45:28.835 5679-5750/com.example.roudy.quickboxtest D/SMACK: RECV (0): <failure xmlns="urn:ietf:params:xml:ns:xmpp-sasl"><not-authorized/></failure>