No class found exception com.squareup.okhttp.logging.HttpLoggingInterceptor

后端 未结 3 683
粉色の甜心
粉色の甜心 2021-01-18 06:15

Even after adding the dependencies and importing the class I am getting java.lang.NoClassDefFoundError: com.squareup.okhttp.logging.HttpLoggingInterceptor.

Can anyon

相关标签:
3条回答
  • 2021-01-18 06:20

    In my case, I found that the versions of the okhttp3 and okhttp3:logging-interceptor dependencies needed to exactly match. So for example:

    ...
    compile 'com.squareup.retrofit2:converter-gson:2.1.0'
    compile 'com.squareup.okhttp3:okhttp:3.4.1'
    compile 'com.squareup.okhttp3:logging-interceptor:3.4.1'
    ...
    
    0 讨论(0)
  • 2021-01-18 06:30

    Also it can be connected with multidex true option in your build.gradle (yes, seems like some devices have problems with multidex apps (read, Samsung))

    If this is your case, switch this flag off and rebuild your project. Consider using

    minifyEnabled true
    shrinkResources true
    

    to reduce your apk size. If it is still too large, that's really weird and bad news, but there are some techniques to put your apk on diet.

    0 讨论(0)
  • 2021-01-18 06:39

    Could be a compatibility problem with retrofit.

    Try with :

    implementation 'com.squareup.okhttp:logging-interceptor:2.5.0'
    

    This post could be help

    App crash on HttpLoggingInterceptor

    0 讨论(0)
提交回复
热议问题