我正在尝试使用ejabberd服务器和smack库来实现一个聊天Messenger,但是很难集成所有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()
}
}
问题:
如何清除错误或可能导致错误的原因。我可能会缺少一些依赖关系?
使用工作服将增加应用程序的大小。我可以在不使用任何库的情况下实现IM而是编写服务器端代码。像使用ejabberd库来处理node-js和与nodejs而不是ejabberd对话的android应用程序一样?
是的,我还有更多东西:
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类时出现错误
如果执行问题中的操作,则他/她将能够集成该库。
我只是运行文件而不是整个项目,这听起来可能是一个愚蠢的错误,但是在构建项目之后,一切都很好。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句