无法连接到android中的openfire服务器

无法连接到android中的openfire服务器,android,xmpp,openfire,Android,Xmpp,Openfire,每当我尝试运行我的应用程序时,就会出现以下错误: Caused by: java.lang.NoSuchMethodError: No static method domainprep(Ljava/lang/String;)Ljava/lang/String; in class Lorg/jxmpp/stringprep/XmppStringPrepUtil; or its super classes (declaration of 'org.jxmpp.stringprep.XmppSt

每当我尝试运行我的应用程序时,就会出现以下错误:

 Caused by: java.lang.NoSuchMethodError: No static method 
 domainprep(Ljava/lang/String;)Ljava/lang/String; in class Lorg/jxmpp/stringprep/XmppStringPrepUtil; or its super classes (declaration of 'org.jxmpp.stringprep.XmppStringPrepUtil' appears in /data/data/app.com.hideout.myapplication/files/instant-run/dex/slice-jxmpp-core-0.3.0_6be45a45890e0c107a4cb82dbe4a33060e3b5f11-classes.dex)
尝试在谷歌上搜索,也导入了jar,因为这些都不起作用

这是我的gradle文件:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "25.0.2"
    defaultConfig {
        applicationId "app.com.hideout.myapplication"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}
dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:23.4.0'
    testCompile 'junit:junit:4.12'
    compile files('libs/smack-tcp-4.2.0.jar')
    compile files('libs/smack-android-extensions-4.1.0-beta1.jar')
}
这是我用来连接xmpp服务器的代码,它是openfire

private class MyLoginTask extends AsyncTask<String, String, String> {
    @Override
    protected String doInBackground(String... params) {
        // Create a connection to the jabber.org server.
        XMPPTCPConnectionConfiguration config = null;
        try {
            config = XMPPTCPConnectionConfiguration.builder()
                     .setXmppDomain(SERVICE)
                    .setUsernameAndPassword(USERNAME,PASSWORD)
                    .setHost(HOST)
                    .setSecurityMode(ConnectionConfiguration.SecurityMode.disabled)
                    .setPort(PORT)
                    .setDebuggerEnabled(true) // to view what's happening in detail
                    .build();
        } catch (XmppStringprepException e) {
            Log.e("app",e.getMessage()+"");
        }

        AbstractXMPPConnection conn1 = new XMPPTCPConnection(config);
        try {
            conn1.connect();
            if(conn1.isConnected()) {
                Log.w("app", "conn done");
            }
            conn1.login();

            if(conn1.isAuthenticated()) {
                Log.w("app", "Auth done");
            }
        }
        catch (Exception e) {
            Log.w("app", e.toString());
        }

        return "";
    }
私有类MyLoginTask扩展异步任务{
@凌驾
受保护的字符串doInBackground(字符串…参数){
//创建到jabber.org服务器的连接。
XMPPTCPConnectionConfiguration=null;
试一试{
config=XMPPTCPConnectionConfiguration.builder()
.setXmppDomain(服务)
.SetUserName和PASSWORD(用户名、密码)
.setHost(主机)
.setSecurityMode(ConnectionConfiguration.SecurityMode.disabled)
.setPort(端口)
.setDebuggerEnabled(true)//查看详细情况
.build();
}捕获(xmppstringpreception e){
Log.e(“app”,e.getMessage()+”);
}
AbstractXMPPConnection conn1=新的XMPPTCPConnection(配置);
试一试{
conn1.connect();
如果(conn1.isConnected()){
Log.w(“应用程序”、“连接完成”);
}
conn1.login();
如果(conn1.isAuthenticated()){
Log.w(“应用程序”、“验证完成”);
}
}
捕获(例外e){
Log.w(“app”,例如toString());
}
返回“”;
}

提前感谢不要使用jar文件…最好像文档中解释的那样,通常通过gradle导入:我现在不使用它…请查看我的gradle文件如果您从
conn1.connect()
得到错误,那么您的配置是错误的。当然,您使用的是jar文件…
编译文件('libs/smack-tcp-4.2.0.jar')
指的是一个jar文件。因此,如果您不使用jar文件,您必须更改配置。正如我所说的,按照文档进行操作,一切都很好。谢谢@Opiatefuchs…之前我在脱机使用依赖项…这很有帮助