Skip to content Skip to sidebar Skip to footer

No Class Found Exception Com.squareup.okhttp.logging.httplogginginterceptor

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

Solution 1:

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'
...

Solution 2:

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

Solution 3:

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.

Post a Comment for "No Class Found Exception Com.squareup.okhttp.logging.httplogginginterceptor"