0

Here are my dependencies,

//retrofit and gson dependencies
compile 'com.google.code.gson:gson:2.6.2'
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'com.squareup.okhttp3:logging-interceptor:3.4.1'
compile 'com.squareup.retrofit2:converter-gson:2.1.0'

and code which uses HttpLoggingInterceptor is like this,

 HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
    interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
    OkHttpClient client = new OkHttpClient.Builder().addInterceptor(interceptor).build();

    retrofit = new Retrofit.Builder()
                        .baseUrl(URL)
                        .client(client)
                        .addConverterFactory(GsonConverterFactory.create())
                        .build();

I have refered to this question and for error which I am getting, they said update dependecies version.I have tried all versions of okHttp.logging-Interceptor but still its not working.Can anyone have any idea where I'm going wrong.

Community
  • 1
  • 1
shalini
  • 355
  • 4
  • 17

2 Answers2

3

Just tested your code, everything seems fine . Please clean your and re-run .

Code_Life
  • 5,742
  • 4
  • 29
  • 49
  • I dont understand what is the reason behind code is not working in the first place.It wasted my 2 hrs for just showing this exception.Clean project did the work.Thanks – shalini Sep 19 '16 at 07:39
1

Just add the same version in all libraries related to Retrofit or change or update the versions. this problem seems is related to conflict versions.

imansdn
  • 968
  • 1
  • 7
  • 17