okHttp加入日志拦截器出现的问题

代码如下

 //可以查看网络请求的日志
        HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
        logging.setLevel(HttpLoggingInterceptor.Level.BODY);

        client = new OkHttpClient.Builder()
                .addInterceptor(logging)
                .connectTimeout(30 * 1000, TimeUnit.MILLISECONDS)
                .readTimeout(30*1000,TimeUnit.MILLISECONDS)
                .writeTimeout(30*1000,TimeUnit.MILLISECONDS)
                .build();
        KLog.d("yus","网路日志拦截");
        requestUrl = url;
        mParams = params;
        return api;

结果出现如图错误

Caused by: java.lang.ClassNotFoundException: Didn’t find class “okhttp3.internal.Platform”

解决方法:把拦截器的版本和okhttp的版本调为一致即可


image.png

你可能感兴趣的:(okHttp加入日志拦截器出现的问题)