Android - 将SendBird(chat api)添加到项目后出现Retrofit错误

时间:2016-08-27 11:55:02

标签: android retrofit sendbird

我的项目工作正常,直到昨天我决定使用SendBird作为聊天API,所以我已阅读其文档并添加到gradle,登录工作正常,它编译并运行没有错误,但是当我去一个发出http请求的激活(w / retrofit),我的应用程序崩溃了这个堆栈跟踪:

java.lang.NoClassDefFoundError:retrofit2.Utils

如果将Sendbird添加到gradle,我只会收到此错误,如果我删除了gradle依赖项的SendBird,则不会发生此错误。我不知道为什么会这样,但这是我的build.gradle(应用程序级别):

apply plugin: 'com.android.application'

android {
compileSdkVersion 24
buildToolsVersion "24"
useLibrary 'org.apache.http.legacy'

defaultConfig {
    applicationId "com.testdevelop.app.br"
    minSdkVersion 14
    multiDexEnabled true
    targetSdkVersion 24
    versionCode 91
    versionName "2.0.4"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
    debug {
        debuggable true
        minifyEnabled false
    }
}


dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.1.1'
compile 'com.android.support:design:24.1.1'
compile 'com.android.support:support-v4:24.1.1'
compile 'com.android.support:multidex:1.0.1'
compile 'com.google.android:flexbox:0.2.2'
compile 'com.google.android.gms:play-services-gcm:9.2.1'
compile 'com.google.android.gms:play-services-analytics:9.2.1'
compile 'com.google.android.gms:play-services-appindexing:9.2.1'
compile 'com.google.android.gms:play-services-auth:9.2.1'
compile 'com.google.code.gson:gson:2.7'
compile 'com.daimajia.swipelayout:library:1.2.0@aar'
compile 'com.afollestad.material-dialogs:core:0.8.6.1'
compile 'com.mixpanel.android:mixpanel-android:4.9.1'
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'com.squareup.retrofit2:converter-gson:2.1.0'
compile 'com.facebook.android:facebook-android-sdk:4.5.0'
compile 'joda-time:joda-time:2.9.4'
compile 'com.nispok:snackbar:2.11.+'
compile 'com.sendbird.sdk:sendbird-android-sdk:3.0.0'
compile files('libs/universal-image-loader-1.9.1.jar')
}

提前致谢。

1 个答案:

答案 0 :(得分:1)

我通过创建包含SendBird和Retrofit库的简单Android项目,使用Retrofit测试了SendBird SDK。

我没有发现任何错误来运行它。

您似乎忘了为您的Retrofit库更新Proguard规则。

这是Retrofit建议的Proguard规则。 http://square.github.io/retrofit/

# Platform calls Class.forName on types which do not exist on Android to determine platform.
-dontnote retrofit2.Platform
# Platform used when running on RoboVM on iOS. Will not be used at runtime.
-dontnote retrofit2.Platform$IOS$MainThreadExecutor
# Platform used when running on Java 8 VMs. Will not be used at runtime.
-dontwarn retrofit2.Platform$Java8
# Retain generic type information for use by reflection by converters and adapters.
-keepattributes Signature
# Retain declared checked exceptions for use by a Proxy instance.
-keepattributes Exceptions