找不到类com.squareup.okhttp.logging.HttpLoggingInterceptor异常 [英] No class found exception com.squareup.okhttp.logging.HttpLoggingInterceptor

查看:240
本文介绍了找不到类com.squareup.okhttp.logging.HttpLoggingInterceptor异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

即使添加了依赖性并导入了类之后,我也得到了java.lang.NoClassDefFoundError: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.

任何人都可以帮忙吗?

Gradle构建文件

Gradle Build file

   apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        applicationId "xyz"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
        multiDexEnabled = true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    repositories {
        mavenCentral()
    }
 }

    dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.android.support:support-v4:23.1.1'
    compile 'com.google.code.gson:gson:2.4'
    compile 'com.android.support:design:23.1.1'
    compile 'com.android.support:cardview-v7:23.1.1'
    compile 'com.google.android.gms:play-services:8.3.0'
    compile 'com.facebook.android:facebook-android-sdk:4.1.0'
    compile 'com.android.support:recyclerview-v7:23.1.1'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.jakewharton:butterknife:7.0.1'
    compile 'com.squareup.retrofit:retrofit:2.0.0-beta2'
    compile 'com.squareup.retrofit:converter-gson:2.0.0-beta2'
    compile 'com.squareup.okhttp:logging-interceptor:2.6.0'
    }

推荐答案

就我而言,我发现okhttp3和okhttp3:logging-interceptor依赖项的版本需要完全匹配.例如:

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

这篇关于找不到类com.squareup.okhttp.logging.HttpLoggingInterceptor异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆