问题
setLevel(okhttp3.logging.HttpLoggingInterceptor.Level)' is deprecated
what should replace with setLevel? to remove the deprecated issue
回答1:
According to the documentation "Moved to var. Replace setLevel(...) with level(...) to fix Java",
Replace setLevel(...)
with level(...)
will fix this issue
example :
HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
logging.level(HttpLoggingInterceptor.Level.BODY);
Happy coding :)
回答2:
for Kotlin
replace :
val logger: HttpLoggingInterceptor =
HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BODY) //Logging Interceptor
with :
val logger = HttpLoggingInterceptor()
logger.level = HttpLoggingInterceptor.Level.BODY
Add your inceptor to okHttpClient
val okkHttpclient = OkHttpClient.Builder()
.addInterceptor(networkConnectionInterceptor)
.addInterceptor(logger)
.build()
Happy Coding...
来源:https://stackoverflow.com/questions/56840495/setlevel-okhttp-logginginterceptor-deprecated