我正在使用Stetho、Retrofit和OkHttp与Chrome工具进行调试,一切似乎都正常,我看到了本地数据库内容,我可以检查我的UI,但是如果我在网络检查启用的情况下向服务器发出一些REST请求,请愿书仍然是“待定”,但是如果我复制URL并粘贴在Chrome选项卡上,请愿就会正确执行,我不知道发生了什么。

这些是我的等级进口品:
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'com.squareup.okhttp3:logging-interceptor:3.9.1'
compile 'com.squareup.retrofit2:converter-gson:2.1.0'
implementation 'com.facebook.stetho:stetho:1.5.0'
implementation 'com.facebook.stetho:stetho-okhttp3:1.5.0'发布于 2018-02-12 16:52:54
我在这里找到了答案https://github.com/facebook/stetho/issues/346
我不小心用了一个普通的拦截器而不是网络拦截器。
所以这是我的错误的版本
HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
logging.setLevel(HttpLoggingInterceptor.Level.BODY);
OkHttpClient.Builder httpClient = new OkHttpClient.Builder();
httpClient.addInterceptor(logging);
httpClient.addInterceptor(new StethoInterceptor());这是正确的版本:
HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
logging.setLevel(HttpLoggingInterceptor.Level.BODY);
OkHttpClient.Builder httpClient = new OkHttpClient.Builder();
httpClient.addInterceptor(logging);
httpClient.addNetworkInterceptor(new StethoInterceptor());https://stackoverflow.com/questions/48751252
复制相似问题