与Android Studio项目啪的集成聊天应用程序 [英] Integrating Smack with Android Studio project for chat application

查看:426
本文介绍了与Android Studio项目啪的集成聊天应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想实现使用ejabberd服务器和咂嘴图书馆聊天信使,但有一个困难时期,以整合所有的罐子和咂嘴的​​依赖关系。我使用的机器人工作室。

I am trying to implement a chat messenger using ejabberd server and smack library but having a hard time to integrate all the jars and dependencies of smack. I am using android Studio.

我的build.gradle(模块):

apply plugin: 'com.android.application'

    android {
        compileSdkVersion 22
        buildToolsVersion "22.0.1"

        defaultConfig {
            applicationId "com.example.nit.xmppclient"
            minSdkVersion 18
            targetSdkVersion 22
            versionCode 1
            versionName "1.0"
        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }
    }

    dependencies {
        compile fileTree(dir: 'libs', include: ['*.jar'])
        compile 'com.android.support:appcompat-v7:22.2.0'

        compile "org.igniterealtime.smack:smack-android:4.1.0"
        compile "org.igniterealtime.smack:smack-tcp:4.1.0"
        compile "org.igniterealtime.smack:smack-android-extensions:4.1.0"

        compile 'org.ogce:xpp3:1.1.6'

    }

首先,我是越来越XMLpullparser错误,那么我说XPP3。但是我加XPP3后,我得到

Firstly I was getting XMLpullparser error then I added xpp3. But after I added xpp3 I am getting

Error:Gradle: Execution failed for task ':app:preDexDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/usr/lib/jvm/java-7-openjdk-amd64/bin/java'' finished with non-zero exit value 1

的build.gradle(项目):

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.2.2'



        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
        maven {
            url 'https://oss.sonatype.org/content/repositories/snapshots'
        }
        mavenCentral()
    }

}

问题:

如何去除错误或者什么可以导致错误的原因。我可能会丢失一些依赖?

How to remove the error or what can be the cause of error. I might be missing some dependency ?

使用罩衫会增加应用程序大小。我可以acheive IM不使用任何库,编写服务器端code来代替。
喜欢使用ejabberd库节点JS和Android应用交谈的的NodeJS而不是ejabberd?

Using smock will increase the app-size. can I acheive IM without using any library and writing server side code instead. Like using ejabberd library for node-js and the android app talking to nodejs instead of ejabberd?

是的,我还有一点:

public class XMPPClient {
    private static int port = 5222;
    private static String host = "my-ip";
    private static String service = "my.com";


    static XMPPTCPConnectionConfiguration conf = XMPPTCPConnectionConfiguration.builder()
            .setServiceName(service)
            .setPort(port)
            .setHost(host)
            .setCompressionEnabled(false).build();
    static XMPPTCPConnection connection = new XMPPTCPConnection(conf);


    public static void register(String username, String password) throws SmackException.NotConnectedException, XMPPException.XMPPErrorException, SmackException.NoResponseException {

        AccountManager accountManager = AccountManager.getInstance(connection);
        accountManager.createAccount(username,password);
    }

    public static  void main (String args[]) throws SmackException.NotConnectedException, XMPPException.XMPPErrorException, SmackException.NoResponseException {

        register("user", "password");

    }


}

我收到当我运行XMPPClient类误差

I am getting the error when i am running the XMPPClient class

推荐答案

看来你需要添加multidex支持。在您的应用程序的文件的build.gradle添加multidex支持

It seems you need to add multidex support. Add multidex support in your app's build.gradle file

 android {
  compileSdkVersion 21
 buildToolsVersion "21.1.0"

defaultConfig {
    ...
    minSdkVersion 14
    targetSdkVersion 21
    ...

    // Enabling multidex support.
    multiDexEnabled true
}
...
}

dependencies {
compile 'com.android.support:multidex:1.0.0'
}

这篇关于与Android Studio项目啪的集成聊天应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆