RN
项目使用 stetho
[toc]
build.gradle配置
compile 'com.facebook.stetho:stetho:1.3.1' compile 'com.facebook.stetho:stetho-okhttp3:1.3.1'
MainApplication.java 添加
import com.facebook.react.modules.network.ReactCookieJarContainer; import com.facebook.stetho.Stetho; import okhttp3.OkHttpClient; import com.facebook.react.modules.network.OkHttpClientProvider; import com.facebook.stetho.okhttp3.StethoInterceptor; import java.util.concurrent.TimeUnit; @Override public void onCreate() { super.onCreate(); SoLoader.init(this,/* native exopackage */ false); Stetho.initializeWithDefaults(this); OkHttpClient client = new OkHttpClient.Builder() .connectTimeout(0,TimeUnit.MILLISECONDS) .readTimeout(0,TimeUnit.MILLISECONDS) .writeTimeout(0,TimeUnit.MILLISECONDS) .cookieJar(new ReactCookieJarContainer()) .addNetworkInterceptor(new StethoInterceptor()) .build(); OkHttpClientProvider.replaceOkHttpClient(client); }
效果截图:
效果截图:
原文链接:https://www.f2er.com/react/303405.html