I use Retrofit2 , updated build.gradle after that the project stopped finding the HttpLoggingInterceptor . In the build.gradle section, the dependencies section now looks like this:
compile 'com.squareup.retrofit2:retrofit:2.2.0' compile 'com.squareup.okhttp3:okhttp:3.6.0' compile 'com.squareup.okhttp3:logging-interceptor:3.6.0' What needs to be changed in build.gradle so that the project can find the HttpLoggingInterceptor ?
Code using the HttpLogginInterceptor :
public BaseApi() { HeaderInterceptor headerInterceptor = new HeaderInterceptor(); HttpLoggingInterceptor logger = new HttpLoggingInterceptor(); logger.setLevel(HttpLoggingInterceptor.Level.BODY); client = new OkHttpClient.Builder() .connectTimeout(60, TimeUnit.SECONDS) .readTimeout(30, TimeUnit.SECONDS) .addInterceptor(logger) .addInterceptor(headerInterceptor) .build(); retrofit = new Retrofit.Builder() .baseUrl(BuildConfig.BASE_URL) .client(client) .addConverterFactory(GsonConverterFactory.create()) .addCallAdapterFactory(RxJavaCallAdapterFactory.create()) .build(); service = retrofit.create(MessengerApi.class); }
compile('com.squareup.retrofit2:retrofit:2.1.0') { exclude module: 'okhttp' }- Yuriy SPb ♦