I am using OkHttp
in my Application and add OkHttp interceptor
to print log. As you see, I only want to import OkHttp interceptor
for debug apk not for release.
if (BuildConfig.DEBUG) {
HttpLoggingInterceptor logging = new HttpLoggingInterceptor(new HttpLoggingInterceptor.Logger() {
@Override
public void log(String message) {
Log.i(TAG, message);
}
});
logging.setLevel(HttpLoggingInterceptor.Level.HEADERS);
mOkHttpClient = new OkHttpClient.Builder().addInterceptor(logging).build();
}else {
mOkHttpClient = new OkHttpClient();
}
I have used debugImplementation 'com.squareup.okhttp3:logging-interceptor:3.9.1'
however when I invoke ./gradlew assembleRelease
it failed because import import okhttp3.logging.HttpLoggingInterceptor;
Is there any way to do that? Thanks in advance.
Edit
The question Import library only for debugging does not work for me.