咂4.2。如果我建立连接,应用程序总是崩溃

时间:2017-07-08 13:38:22

标签: android crash xmpp smack

我在堆栈中读了很多分辨率,但我无法解决这个问题。

  1. 我给我的应用程序互联网预先
  2. 我使用asynctask
  3. 我的问题是一样的。如果我开始构建
  4. ,我的应用程序总是崩溃

    我尝试用try catch来做。我也尝试用预期的抛出来做但没有任何帮助。我希望有一位能帮我解决这个问题的专家。没有Builder,应用程序运行正常没有问题

    MainActivity.class

    import android.support.v7.app.AppCompatActivity;
    import android.os.Bundle;
    
    public class MainActivity extends AppCompatActivity {
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            connectXmpp con= new connectXmpp();
            con.execute();
        }
    }
    

    connectXmpp.class

    import android.os.AsyncTask;
    
    
    import org.jivesoftware.smack.ConnectionConfiguration;
    import org.jivesoftware.smack.tcp.XMPPTCPConnection;
    import org.jivesoftware.smack.tcp.XMPPTCPConnectionConfiguration;
    
    /**
     * Created by saddam on 08.07.2017.
     */
    
    public class connectXmpp extends AsyncTask <Void,Void,Void>{
        public static XMPPTCPConnection connection;
        @Override
        protected Void doInBackground(Void... voids) {
    
    
            XMPPTCPConnectionConfiguration.Builder config = XMPPTCPConnectionConfiguration
                    .builder();
            config.setUsernameAndPassword("username","pw");
            config.setSecurityMode(ConnectionConfiguration.SecurityMode.disabled);
            config.setHost("dismail.de");
            config.setPort(5222);
            config.setDebuggerEnabled(true);
            XMPPTCPConnection.setUseStreamManagementDefault(true);
            connection = new XMPPTCPConnection(config.build());
    
            return null;
        }
    
        @Override
        protected void onProgressUpdate(Void... values) {
            super.onProgressUpdate(values);
        }
    
        @Override
        protected void onPostExecute(Void aVoid) {
            super.onPostExecute(aVoid);
        }
    
    
    
    }
    

1 个答案:

答案 0 :(得分:0)

好吧好像smack 4.2有一个bug。使用此依赖项解决了我的问题:

compile 'org.igniterealtime.smack:smack-android:4.1.1'
   compile 'org.igniterealtime.smack:smack-android-extensions:4.1.1'
   compile 'org.igniterealtime.smack:smack-core:4.1.1'
   compile 'org.igniterealtime.smack:smack-tcp:4.1.1'
   compile 'org.igniterealtime.smack:smack-extensions:4.1.1'
   compile 'org.igniterealtime.smack:smack-experimental:4.1.1'
   compile 'org.igniterealtime.smack:smack-resolver-minidns:4.1.1'
   compile 'org.igniterealtime.smack:smack-sasl-provided:4.1.1'
   compile 'org.igniterealtime.smack:smack-im:4.1.1'
   compile 'org.jxmpp:jxmpp-core:0.4.2-beta1'
   compile 'org.jxmpp:jxmpp-util-cache:0.4.2-beta1'
   compile 'de.measite.minidns:minidns:0.1.1'
相关问题