Stetho
参考: github 地址:https://github.com/facebook/stetho
- app_gradle 添加依赖
api 'com.facebook.stetho:stetho:1.5.0'
api 'com.facebook.stetho:stetho-okhttp3:1.5.0'
Application 初始化
if(BuildConfig.DEBUG){ Stetho.initializeWithDefaults(this); }
OkHttp添加网络拦截器
OkHttpClient.Builder builder = new OkHttpClient.Builder() .addNetworkInterceptor(new StethoInterceptor()
顺便提一下OkHttp添加请求Head头
public class OkHttpRequestHeadIntercepter implements Interceptor { @Override public Response intercept(Chain chain) throws IOException { Request.Builder builder = chain.request().newBuilder() .addHeader("gg-version", BuildConfig.VERSION_NAME); if (UserUtils.isLogin()) { builder.addHeader("gg-token", UserUtils.getToken()); } Request request = builder.build(); return chain.proceed(request); } }
Fidder抓包来了
下载地址:
https://www.telerik.com/download/fiddler
配置步骤参考
https://blog.csdn.net/shimengran107/article/details/78644862
Fidder 过滤条件参考
https://www.cnblogs.com/sjl179947253/p/7627250.html
抓包工具有很多,但原理大体就是根据wifi代理进行url截取处理,Wind启动Fiddler后,其内部就相当于一个虚拟的跟你电脑IP一样的代理服务区,这是你会发现Chrome网页打不开,不安全,是因为证书问题,需要把Fiddler的安全证书加到Chrome证书列表里!!!手机WiFi连接代理后,其浏览器打不开网页,输入:ip:post端口 下载证书安装!!!(所谓的代理,也就类似于访问的是你设置代理的服务器,,相当于Shadowsock代理服务器翻墙一样)
Fiddler 抓包好像只能抓Debug的包,Release(签名)的Url数据抓不到,包括从应用市场下载的Apk
- 又用到了之前的Chrome的SwitchyOmega插件—为了是防止代理翻墙网络有限,有些不用翻墙的用外网浪费,这个是自动内外网切换!!!