gpt4 book ai didi

android - 无法在 HttpLoggingInterceptor Retrofit 2.0 上解析 setLevel

转载 作者:太空宇宙 更新时间:2023-11-03 11:28:39 25 4
gpt4 key购买 nike

我正在使用 Retrofit,我想记录我的响应和其他事情,我正在使用这个 https://futurestud.io/tutorials/retrofit-2-log-requests-and-responses类型,但我遇到了 Cant resolve setLevel 错误

HttpLoggingInterceptor logging = new HttpLoggingInterceptor();  

logging.setLevel(Level.BODY); // i am getting error on this

OkHttpClient.Builder httpClient = new OkHttpClient.Builder();

httpClient.addInterceptor(logging); //this is also getting error

我正在用这个编译 'com.squareup.okhttp3:logging-interceptor:3.3.1' 和 Retrofit编译 'com.squareup.retrofit2:converter-gson:2.1.0' 依赖项。

This is where i got error

最佳答案

getClient() 方法中编写您的拦截器 代码

public class RestClient {

public getClient() {

HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
logging.setLevel(HttpLoggingInterceptor.Level.BODY);
}
}

关于android - 无法在 HttpLoggingInterceptor Retrofit 2.0 上解析 setLevel,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39784243/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com