java.lang.NoClassDefFoundError : okhttp3. OkHttpClient$Builder

标签 java android retrofit rx-java2 okhttp

我正在寻找 same issue并尝试使用指定的解决方案,但我仍然遇到与下面相同的错误

java.lang.NoClassDefFoundError: Failed resolution of: Lokhttp3/OkHttpClient$Builder;

Caused by: java.lang.ClassNotFoundException: Didn't find class "okhttp3.OkHttpClient$Builder" on path: DexPathList[[zip file "path" ]]

我的 gradle 是这样的

compile 'io.realm:android-adapters:1.4.0'
compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
compile 'io.reactivex:rxandroid:1.1.0' 
compile 'io.reactivex:rxjava:1.1.3'    


compile 'com.squareup.retrofit2:retrofit:2.3.0'
compile 'com.squareup.retrofit2:converter-gson:2.3.0'
compile 'com.squareup.retrofit2:adapter-rxjava:2.3.0'
compile 'com.squareup.okhttp3:okhttp:3.9.0'

我有扩展 MultidexApplication 的应用程序类。

最佳答案

用这个更新你的 gradle 文件

android {
  defaultConfig {
    multiDexEnabled true
  }
}

关于java.lang.NoClassDefFoundError : okhttp3. OkHttpClient$Builder,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46424438/

相关文章:

android - 在中国发布应用程序(阻止谷歌等)

java - 使用 Retrofit 将图像上传到 amazon s3

android - 改造具有不同对象的数组

java - 已弃用的新 Double(double) 的替代方案

java - Double不是抽象的,并且不会重写ListInterface中的抽象方法getNext()吗?

java - 用户注册的确认电子邮件如何工作?

java - 如何在android中以编程方式使用HFP-bluetooth连接到远程电话

android - Google App Invite - 主题更改

java - SwingWorker 和 Executor 的区别

android - RxJava/Retrofit - 如何强制用户使用订阅者的特定子类?