我一直在这里阅读大量的决议,但我无法解决此问题。
我试图用catch来做到这一点。我也试图用预期的方法做到这一点,但没有任何帮助。我希望有一个可以帮助我摆脱困境的专家。如果没有构建器,则应用程序可以正常运行而不会出现问题
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);
}
}
最佳答案
好吧,似乎smack 4.2有一个错误。我的问题通过使用此依赖关系解决:
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'
关于android - 打点4.2。如果我建立连接,应用程序总是崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44986850/