{"id":40,"date":"2015-05-21T05:42:40","date_gmt":"2015-05-21T05:42:40","guid":{"rendered":"https:\/\/boochlin.com\/?p=40"},"modified":"2015-05-21T05:49:21","modified_gmt":"2015-05-21T05:49:21","slug":"chrome-dev-tool-for-android-steho","status":"publish","type":"post","link":"https:\/\/boochlin.com\/?p=40","title":{"rendered":"Chrome dev tool for android &#8211;  steho"},"content":{"rendered":"<h3>facebook \u00a0\u958b\u767c\u7684\u958b\u6e90\u5de5\u5177 \u00a0&#8220;steheo&#8221;<\/h3>\n<div><\/div>\n<div>\u5b98\u7db2\u7c21\u4ecb<\/div>\n<div>\u300cStetho is a sophisticated debug bridge for Android applications. When enabled, developers have access to the Chrome Developer Tools feature natively part of the Chrome desktop browser. Developers can also choose to enable the optional dumpapp tool which offers a powerful command-line interface to application internals.\u300d<\/div>\n<div>\u9019\u500b\u55ae\u5b57\u662f\u807d\u8a3a\u5668\uff0c\u4e00\u8a00\u4ee5\u853d\u4e4b\u300c\u53ef\u4ee5\u7528chrome devtools\u5c31\u53ef\u4ee5debug android\u300d<\/div>\n<div>1. network inspection<\/div>\n<div>2. database inspection<\/div>\n<div>3. view hierarchy<\/div>\n<div>\u5176\u5be6\u5e02\u9762\u4e0a\u4e5f\u6709\u4e00\u4e9b\u60f3\u95dc\u5de5\u5177\uff0c\u751a\u81f3\u539f\u751f\u7684android device monitor\u90fd\u53ef\u4ee5\u5f88\u731b\u4e86<\/div>\n<div>\u4f46\u662f\u5927\u6982\u6700\u5927\u8a98\u56e0\u5c31\u5728\u65bc\u4ed6\u53ef\u4ee5\u514droot\u5c31\u53ef\u4ee5\u89c0\u6e2c\u4e86<\/div>\n<div>\u56e0\u6b64\u6211\u60f3\u5230\u7684scenrio \u00a0\u5c31\u662f\u62ff\u5230user\u7248\u7684\u6a5f\u5668\uff0c\u60f3\u8981\u770b\u88e1\u9762\u7684\u8cc7\u6599\uff0c<wbr \/>\u9019\u500b\u5c31\u53ef\u80fd\u6709\u9ede\u7528<\/div>\n<div>\u53e6\u5916\u4e00\u500b\u5c31\u662fnetwork inspection \u00a0\u9019\u500b\u53ef\u4ee5\u52d5\u614b\u89c0\u6e2c \u7db2\u8def\u4e0b\u8f09\u8cc7\u6599\u7684\u5927\u5c0f\uff0c\u8017\u6642<\/div>\n<div>\u73a9\u73a9\u770b\u5427<\/div>\n<div><\/div>\n<p><!--more--><\/p>\n<div>getting started<\/div>\n<div>\u5b98\u7db2\u6559\u5b78<\/div>\n<div><a href=\"http:\/\/facebook.github.io\/stetho\/\" target=\"_blank\">http:\/\/facebook.github.io\/<wbr \/>stetho\/<\/a><\/div>\n<div>\u4e2d\u6587\u7248<\/div>\n<div><a href=\"http:\/\/stormzhang.com\/android\/2015\/03\/05\/android-debug-use-chrome\/\" target=\"_blank\">http:\/\/stormzhang.com\/android\/<wbr \/>2015\/03\/05\/android-debug-use-<wbr \/>chrome\/<br \/>\n<\/a><\/div>\n<div><\/div>\n<div>\u81ea\u5df1\u52d5\u624b\u6539<\/div>\n<div>1.<\/div>\n<div>\n<pre>dependencies { compile 'com.facebook.stetho:stetho:1.<wbr \/>1.1' }\r\n<\/pre>\n<\/div>\n<div>2. \u518dapplication\u88e1\u52a0\u5165<\/div>\n<div>\n<pre>public class MyApplication extends Application { \r\n    public void onCreate() { \r\n         super.onCreate();\r\n         Stetho.initialize( Stetho.newInitializerBuilder(this).enableDumpapp(\r\n              Stetho.defaultDumperPluginsPro<wbr \/>vider(this)) .enableWebKitInspector(\r\n              Stetho.defaultInspectorModules<wbr \/>Provider(this)) .build());\r\n    }\r\n }\r\n<\/pre>\n<\/div>\n<div>3. \u7db2\u8def\u89c0\u6e2c\u6bd4\u8f03\u9ebb\u7169 \u00a0\u8981\u5728http \u76f8\u95dcclass \u00a0\u88e1\u505a\u6514\u622a<\/div>\n<div>\u4ee5okhttp\u4f86\u8aaa<\/div>\n<pre>OkHttpClient client = new OkHttpClient();\r\nclient.networkInterceptors().add(new StethoInterceptor());\r\n<\/pre>\n<div>\u00a0\u4f7f\u7528\u524d\u8981\u8a18\u5f97<\/div>\n<pre>dependencies {\r\n  \/\/ \u5404\u81ea\u53d6\u7528\r\n  compile 'com.facebook.stetho:stetho-okhttp:1.0.1'\r\n  compile 'com.facebook.stetho:stetho-urlconnection:1.0.1'\r\n}\r\n<\/pre>\n<div>\u00a0\u5982\u679c\u662fHttpURLConnection \u9019\u5c31\u6bd4\u8f03\u9ebb\u7169<\/div>\n<div>\u9700\u8981\u5728header \u52a0\u5165\u53ef\u89e3\u69cbgzip \u4e26\u4ee5StethoURLConnectionManager\u53bb\u505a\u7d71\u5408\u8655\u7406<\/div>\n<div><\/div>\n<div>\u00a0\u5982\u679c\u8981\u8ddfgoogle \u51fa\u7684volley \u505a\u6574\u5408\uff0c\u53ef\u4ee5\u53c3\u8003<\/div>\n<div><a title=\"volley integrate\" href=\"http:\/\/ligol.github.io\/blog\/2015\/05\/05\/discovering-and-using-stetho-with-some-network-library\/\" target=\"_blank\">\u00a0http:\/\/ligol.github.io\/blog\/2015\/05\/05\/discovering-and-using-stetho-with-some-network-library\/<\/a><\/div>\n<div>\u5176\u5be6\u5c31\u662f\u5148\u5c07okhttp \u4f5c\u70bavolley \u7db2\u8def\u5e95\u5c64\u5de5\u4f5c\u8005\u4e26\u52a0\u5165\u89c0\u6e2c\u8005\u65bc\u5176\u4e2d<\/div>\n<div>\u7136\u5f8c\u653e\u5165 volley \u7684work queue,<\/div>\n<div>okhttpstack\u662f\u53e6\u5916\u5beb\u7684\uff0c\u4e3b\u8981\u662f\u5c07\u6709\u95dc\u6e2c\u8005\u7684okhttp \u52a0\u5165httpstack<\/div>\n<div>\u7684\u5be6\u505a\u6d41\u7a0b\u88e1\u2026<\/div>\n<div><\/div>\n<div>4. \u6700\u5f8c\u958b\u555f\u4f60\u7684chrome browserr\u7136\u5f8c\u518d\u7db2\u5740\u5217\u8f38\u5165<\/div>\n<div>\n<pre>chrome:\/\/inspect\r\n<\/pre>\n<\/div>\n<div>\u5927\u529f\u544a\u6210<\/div>\n","protected":false},"excerpt":{"rendered":"<p>facebook \u00a0\u958b\u767c\u7684\u958b\u6e90\u5de5\u5177 \u00a0&#8220;steheo&#8221; \u5b98\u7db2\u7c21\u4ecb \u300cStetho is a sophisticated debug bridge for Android app&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[6,48],"_links":{"self":[{"href":"https:\/\/boochlin.com\/index.php?rest_route=\/wp\/v2\/posts\/40"}],"collection":[{"href":"https:\/\/boochlin.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/boochlin.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/boochlin.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/boochlin.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=40"}],"version-history":[{"count":0,"href":"https:\/\/boochlin.com\/index.php?rest_route=\/wp\/v2\/posts\/40\/revisions"}],"wp:attachment":[{"href":"https:\/\/boochlin.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=40"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/boochlin.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=40"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/boochlin.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=40"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}