Stetho

偶然了解Stetho,尝试加入了Widgets套餐

引入步骤
  • 模块gradle中引入依赖:
  dependencies { 
    compile 'com.facebook.stetho:stetho-okhttp3:1.5.0' 
  } 
  • 如果需要监测网络数据,需要增加依赖(我这里使用的是okhttp3网络框架):
 dependencies { 
    compile 'com.facebook.stetho:stetho-okhttp3:1.5.0' 
  } 

ps:平时都是用Charles抓包的,功能应该都是一样的,主要是能在chrome上使用。

  • application初始化:
public class MyApplication extends Application {
  public void onCreate() {
    super.onCreate();
    Stetho.initializeWithDefaults(this);
  }
}
  • 监测网络时需要在Okhttp中增加网络拦截器:
new OkHttpClient.Builder()
    .addNetworkInterceptor(new StethoInterceptor())
    .build();

当然,如果使用Retrofit,你可以如下构建:

 OkHttpClient client = new OkHttpClient.Builder()
                .addNetworkInterceptor(new StethoInterceptor())
                .build();

        Retrofit retrofit = new Retrofit.Builder()
                .client(client)
                ...
chrome device

点击inspect可以开始查看到相关数据了。查看数据库,这是我觉得最方便的了:

db

意外发现x5内核在chrome上自带调试:

x5

以及布局层级的检查:

view
  • 如果有打开弹出的小窗口白屏的,需要翻墙一下即可。
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容