这是我的应用程序类,然后是okhttp初始化。除网络电话外我能调试的所有内容
public class App extends BaseApp {
@Override
public void onCreate() {
ActivityLifecycleCallback.register(this);
Stetho.initialize(
Stetho.newInitializerBuilder(this)
.enableDumpapp(Stetho.defaultDumperPluginsProvider(this))
.enableWebKitInspector(Stetho.defaultInspectorModulesProvider(this))
.build());
}
}
这是OkHttpClass
private static OkHttpClient okHttpClient = new OkHttpClient();
private static OkHttpClient getOkHttpClient() {
if (okHttpClient == null) {
okHttpClient = new OkHttpClient();
okHttpClient.networkInterceptors().add(new StethoInterceptor());
}
return okHttpClient;
}
答案 0 :(得分:1)
正如@guilaume_fr所说,
private static OkHttpClient okHttpClient;
永远不会为null,因为您已初始化它。 尝试删除声明,只需写下@Autowired
请接受并关闭此问题。