我正在尝试使用ejabberd服务器和smack库来实现聊天信使但是很难整合所有的jar和smack的依赖项。我正在使用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之后我得到了
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()
}
}
问题:
如何删除错误或可能导致错误的原因。我可能会错过一些依赖?
使用smock会增加app尺寸。我可以在不使用任何库和编写服务器端代码的情况下实现IM。 就像使用ejabberd库的node-js和android应用程序与nodejs而不是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类时遇到错误
答案 0 :(得分:1)
您似乎需要添加multidex支持。在app的build.gradle文件中添加multidex支持
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'
}
答案 1 :(得分:0)
尝试更改您的依赖项并使用gradles构建
compile 'org.igniterealtime.smack:smack-android:4.1.6'
compile 'org.igniterealtime.smack:smack-tcp:4.1.6'
compile 'org.igniterealtime.smack:smack-im:4.1.6'
compile 'org.igniterealtime.smack:smack-extensions:4.1.6'
答案 2 :(得分:0)
如果有人在问题中做了什么,他/她将能够整合图书馆。
我只是运行文件而不是整个项目,这听起来可能是一个愚蠢的错误但是在构建项目之后一切正常。