{"id":40,"date":"2015-05-21T05:42:40","date_gmt":"2015-05-21T05:42:40","guid":{"rendered":"https:\/\/boochlin.com\/?p=40"},"modified":"2026-09-19T18:04:15","modified_gmt":"2026-09-19T18:04:15","slug":"chrome-dev-tool-for-android-steho","status":"publish","type":"post","link":"https:\/\/boochlin.com\/?p=40","title":{"rendered":"Chrome dev tool for android \u2013  steho"},"content":{"rendered":"<h3>facebook \u00a0\u958b\u767c\u7684\u958b\u6e90\u5de5\u5177 \u00a0\u201csteheo\u201d<\/h3>\n<p>\u5b98\u7db2\u7c21\u4ecb<br \/>\n\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<br \/>\n\u9019\u500b\u55ae\u5b57\u662f\u807d\u8a3a\u5668\uff0c\u4e00\u8a00\u4ee5\u853d\u4e4b\u300c\u53ef\u4ee5\u7528chrome devtools\u5c31\u53ef\u4ee5debug android\u300d<\/p>\n<ol>\n<li>network inspection<\/li>\n<li>database inspection<\/li>\n<li>view hierarchy<br \/>\n\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<br \/>\n\u4f46\u662f\u5927\u6982\u6700\u5927\u8a98\u56e0\u5c31\u5728\u65bc\u4ed6\u53ef\u4ee5\u514droot\u5c31\u53ef\u4ee5\u89c0\u6e2c\u4e86<br \/>\n\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\u9019\u500b\u5c31\u53ef\u80fd\u6709\u9ede\u7528<br \/>\n\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<br \/>\n\u73a9\u73a9\u770b\u5427<\/li>\n<\/ol>\n<p>getting started<br \/>\n\u5b98\u7db2\u6559\u5b78<br \/>\n<a href=\"http:\/\/facebook.github.io\/stetho\/\">http:\/\/facebook.github.io\/stetho\/<\/a><br \/>\n\u4e2d\u6587\u7248<\/p>\n<p><a href=\"http:\/\/stormzhang.com\/android\/2015\/03\/05\/android-debug-use-chrome\/\">http:\/\/stormzhang.com\/android\/2015\/03\/05\/android-debug-use-chrome\/<\/a><\/p>\n<p>\u81ea\u5df1\u52d5\u624b\u6539<br \/>\n1.<\/p>\n<pre><code class=\"hljs language-groovy\">dependencies { compile <span class=\"hljs-string\">&#x27;com.facebook.stetho:stetho:1.1.1&#x27;<\/span> }<\/code><\/pre>\n<ol start=\"2\">\n<li>\u518dapplication\u88e1\u52a0\u5165<\/li>\n<\/ol>\n<pre><code class=\"hljs language-java\"><span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-keyword\">class<\/span> <span class=\"hljs-title class_\">MyApplication<\/span> <span class=\"hljs-keyword\">extends<\/span> <span class=\"hljs-title class_\">Application<\/span> { \n    <span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-type\">void<\/span> <span class=\"hljs-title function_\">onCreate<\/span><span class=\"hljs-params\">()<\/span> { \n         <span class=\"hljs-built_in\">super<\/span>.onCreate();\n         Stetho.initialize( Stetho.newInitializerBuilder(<span class=\"hljs-built_in\">this<\/span>).enableDumpapp(\n              Stetho.defaultDumperPluginsProvider(<span class=\"hljs-built_in\">this<\/span>)) .enableWebKitInspector(\n              Stetho.defaultInspectorModulesProvider(<span class=\"hljs-built_in\">this<\/span>)) .build());\n    }\n }<\/code><\/pre>\n<ol start=\"3\">\n<li>\u7db2\u8def\u89c0\u6e2c\u6bd4\u8f03\u9ebb\u7169 \u00a0\u8981\u5728http \u76f8\u95dcclass \u00a0\u88e1\u505a\u6514\u622a<br \/>\n\u4ee5okhttp\u4f86\u8aaa<\/li>\n<\/ol>\n<pre><code class=\"hljs language-java\"><span class=\"hljs-type\">OkHttpClient<\/span> <span class=\"hljs-variable\">client<\/span> <span class=\"hljs-operator\">=<\/span> <span class=\"hljs-keyword\">new<\/span> <span class=\"hljs-title class_\">OkHttpClient<\/span>();\nclient.networkInterceptors().add(<span class=\"hljs-keyword\">new<\/span> <span class=\"hljs-title class_\">StethoInterceptor<\/span>());<\/code><\/pre>\n<p>\u00a0\u4f7f\u7528\u524d\u8981\u8a18\u5f97<\/p>\n<pre><code class=\"hljs language-groovy\">dependencies {\n  <span class=\"hljs-comment\">\/\/ \u5404\u81ea\u53d6\u7528<\/span>\n  compile <span class=\"hljs-string\">&#x27;com.facebook.stetho:stetho-okhttp:1.0.1&#x27;<\/span>\n  compile <span class=\"hljs-string\">&#x27;com.facebook.stetho:stetho-urlconnection:1.0.1&#x27;<\/span>\n}<\/code><\/pre>\n<p>\u00a0\u5982\u679c\u662fHttpURLConnection \u9019\u5c31\u6bd4\u8f03\u9ebb\u7169<br \/>\n\u9700\u8981\u5728header \u52a0\u5165\u53ef\u89e3\u69cbgzip \u4e26\u4ee5StethoURLConnectionManager\u53bb\u505a\u7d71\u5408\u8655\u7406<\/p>\n<p>\u00a0\u5982\u679c\u8981\u8ddfgoogle \u51fa\u7684volley \u505a\u6574\u5408\uff0c\u53ef\u4ee5\u53c3\u8003<br \/>\n<a href=\"http:\/\/ligol.github.io\/blog\/2015\/05\/05\/discovering-and-using-stetho-with-some-network-library\/\">http:\/\/ligol.github.io\/blog\/2015\/05\/05\/discovering-and-using-stetho-with-some-network-library\/<\/a><br \/>\n\u5176\u5be6\u5c31\u662f\u5148\u5c07okhttp \u4f5c\u70bavolley \u7db2\u8def\u5e95\u5c64\u5de5\u4f5c\u8005\u4e26\u52a0\u5165\u89c0\u6e2c\u8005\u65bc\u5176\u4e2d<br \/>\n\u7136\u5f8c\u653e\u5165 volley \u7684work queue,<br \/>\nokhttpstack\u662f\u53e6\u5916\u5beb\u7684\uff0c\u4e3b\u8981\u662f\u5c07\u6709\u95dc\u6e2c\u8005\u7684okhttp \u52a0\u5165httpstack<br \/>\n\u7684\u5be6\u505a\u6d41\u7a0b\u88e1\u2026<\/p>\n<ol start=\"4\">\n<li>\u6700\u5f8c\u958b\u555f\u4f60\u7684chrome browserr\u7136\u5f8c\u518d\u7db2\u5740\u5217\u8f38\u5165<\/li>\n<\/ol>\n<pre><code class=\"hljs language-plaintext\">chrome:\/\/inspect<\/code><\/pre>\n<p>\u5927\u529f\u544a\u6210<\/p>\n","protected":false},"excerpt":{"rendered":"<p>facebook \u00a0\u958b\u767c\u7684\u958b\u6e90\u5de5\u5177 \u00a0\u201csteheo\u201d \u5b98\u7db2\u7c21\u4ecb \u300cStetho is a sophistic [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[168],"tags":[198,263,290,294],"_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":4,"href":"https:\/\/boochlin.com\/index.php?rest_route=\/wp\/v2\/posts\/40\/revisions"}],"predecessor-version":[{"id":1564,"href":"https:\/\/boochlin.com\/index.php?rest_route=\/wp\/v2\/posts\/40\/revisions\/1564"}],"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}]}}