Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/218.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/svg/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 重击4.2。如果我建立连接,应用程序总是崩溃_Android_Crash_Xmpp_Smack - Fatal编程技术网

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

Android 重击4.2。如果我建立连接,应用程序总是崩溃,android,crash,xmpp,smack,Android,Crash,Xmpp,Smack,我在堆栈中读到了很多分辨率,但我无法解决这个问题 我对我的应用程序给予互联网优先许可 我使用异步任务 我的问题也一样。如果我开始构建,我的应用程序总是会崩溃 我试着用try-catch做这件事。我也试着用预期的投掷来做,但没有任何帮助。我希望有一个能帮我走出这地狱的猛击专家。没有构建器,应用程序运行正常,没有问题 主课 import android.support.v7.app.AppCompatActivity; import android.os.Bundle; public class

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

  • 我对我的应用程序给予互联网优先许可
  • 我使用异步任务
  • 我的问题也一样。如果我开始构建,我的应用程序总是会崩溃
  • 我试着用try-catch做这件事。我也试着用预期的投掷来做,但没有任何帮助。我希望有一个能帮我走出这地狱的猛击专家。没有构建器,应用程序运行正常,没有问题

    主课

    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);
        }
    
    
    
    }
    
    导入android.os.AsyncTask;
    导入org.jivesoftware.smack.ConnectionConfiguration;
    导入org.jivesoftware.smack.tcp.XMPPTCPConnection;
    导入org.jivesoftware.smack.tcp.xmpptcpcconnectionconfiguration;
    /**
    *萨达姆于2017年7月8日创建。
    */
    公共类connectXmpp扩展异步任务{
    公共静态XMPPTCP连接;
    @凌驾
    受保护的空位背景(空位…空位){
    XMPPTCPConnectionConfiguration.Builder config=XMPPTCPConnectionConfiguration
    .builder();
    config.setUsernameAndPassword(“用户名”、“密码”);
    config.setSecurityMode(ConnectionConfiguration.SecurityMode.disabled);
    config.setHost(“demail.de”);
    配置设置端口(5222);
    config.setDebuggerEnabled(true);
    XMPPTCPConnection.setUseStreamManagementDefault(true);
    连接=新的XMPPTCPConnection(config.build());
    返回null;
    }
    @凌驾
    受保护的void onProgressUpdate(void…值){
    super.onProgressUpdate(值);
    }
    @凌驾
    受保护的void onPostExecute(void避免){
    super.onPostExecute(避免);
    }
    }
    
    好的,似乎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'
    

    我建议也发布异常和stacktrace,否则没有人能够帮助您。