美文网首页
Android调试工具:Stetho

Android调试工具:Stetho

作者: 倩shrimp | 来源:发表于2016-09-09 12:45 被阅读58次

今天收获一枚强大的Android调试工具:Stetho,针对OkHttp+Stetho+Chrome,可以调试网络请求、数据库等,为了不遗忘记录下来以便自己随时查看。

stetho官网

使用方式:
1、添加依赖:

dependencies {
    compile'com.facebook.stetho:stetho:1.4.0'
    compile'com.facebook.stetho:stetho-okhttp3:1.4.0'
}

2、在Application的onCreate()里面初始化:

Stetho.initialize(Stetho
    .newInitializerBuilder(this)
    .enableDumpapp(Stetho.defaultDumperPluginsProvider(this))
    .enableWebKitInspector(
          Stetho.defaultInspectorModulesProvider(this)).build());

3、OkHttp添加拦截:

mOkHttpClient=newOkHttpClient.Builder()
.addNetworkInterceptor(newStethoInterceptor())
.build();

4、打开chrome输入网址:chrome://inspect/

点击inspect就会打开如下的界面:


第一次打开的时候我是空白的,后来搜了下原来是第一次需要翻墙一下,本人修改了hosts里面的内容就可以了;
网络部分:


数据库、SharedPreferences部分:


相关文章

网友评论

      本文标题:Android调试工具:Stetho

      本文链接:https://www.haomeiwen.com/subject/zvmeettx.html