我正在Android中构建基于webRTC的通信应用程序。它内部有一个聊天应用程序,在真实设备和模拟器中运行测试时,我一直收到有关socketIO的错误。
我从“https://github.com/socketio/socket.io-client-java”下载“socket.io-client-java-master”文件,并将依赖项放在pom.xml和bundle.gradle文件中。但是我认为现在有一些我想念的东西。以下是错误代码。
安装socketIO.java的正确方法是什么?我希望我能从许多专家的意见中得到一些启示。
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/github/nkzawa/socketio/client/IO$Options;
at sg.com.temasys.skylink.sdk.rtc.bj.e(Unknown Source)
at sg.com.temasys.skylink.sdk.rtc.bj.<init>(Unknown Source)
at sg.com.temasys.skylink.sdk.rtc.bg.connect(Unknown Source)
at sg.com.temasys.skylink.sdk.rtc.bz.run(Unknown Source)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5349)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:908)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:703)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.github.nkzawa.socketio.client.IO$Options" on path: DexPathList[[zip file "/data/app/com.example.sungpah.sungpahfirst-1/base.apk"],nativeLibraryDirectories=[/data/app/com.example.sungpah.sungpahfirst-1/lib/arm, /vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at sg.com.temasys.skylink.sdk.rtc.bj.e(Unknown Source)
at sg.com.temasys.skylink.sdk.rtc.bj.<init>(Unknown Source)
at sg.com.temasys.skylink.sdk.rtc.bg.connect(Unknown Source)
at sg.com.temasys.skylink.sdk.rtc.bz.run(Unknown Source)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5349)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:908)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:703)
Suppressed: java.lang.ClassNotFoundException: com.github.nkzawa.socketio.client.IO$Options
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 13 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available
以下是我的gradle设置状态。
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.example.sungpah.sungpahfirst"
minSdkVersion 15
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets {
main.jni.srcDirs = []
main.jniLibs.srcDirs = ['libs']
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.1'
compile ('io.socket:socket.io-client:0.7.0') {
// excluding org.json which is provided by Android
exclude group: 'org.json', module: 'json'
}
}
我没有从我下载的内容中更改pom.xml文件。