<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Shailesh Baldaniya on Medium]]></title>
        <description><![CDATA[Stories by Shailesh Baldaniya on Medium]]></description>
        <link>https://medium.com/@Shailesh351?source=rss-55126c07c5cf------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*sYjPpVf3E5dQVTsbfH1mPQ.jpeg</url>
            <title>Stories by Shailesh Baldaniya on Medium</title>
            <link>https://medium.com/@Shailesh351?source=rss-55126c07c5cf------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 10:58:32 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@Shailesh351/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Debugging using Stetho in Open Event Android]]></title>
            <link>https://medium.com/@Shailesh351/debugging-using-stetho-in-open-event-android-cde8e06db916?source=rss-55126c07c5cf------2</link>
            <guid isPermaLink="false">https://medium.com/p/cde8e06db916</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[gsoc]]></category>
            <category><![CDATA[fossasia]]></category>
            <category><![CDATA[debugging]]></category>
            <dc:creator><![CDATA[Shailesh Baldaniya]]></dc:creator>
            <pubDate>Tue, 27 Jun 2017 15:18:19 GMT</pubDate>
            <atom:updated>2017-06-28T04:21:45.958Z</atom:updated>
            <content:encoded><![CDATA[<p>The <a href="https://github.com/fossasia/open-event-android">Open Event Android</a> project helps event organizers to generator Apps (apk format) for their events/conferences by providing api end point or zip generated using <a href="https://github.com/fossasia/open-event-orga-server">Open Event server</a>. In this android app data is fetched from the internet using network calls to the <a href="https://github.com/fossasia/open-event-orga-server">Open Event server</a> and the data of the event is stored in a database. It is difficult to debug an app with so many network calls and database connectivity. A way to approach this is using Stetho which is very helpful tool for debugging an app which deals with network calls and database.</p><p>Stetho is Facebook’s open source project works as debug bridge for android applications which gives powerful Chrome Developers Tools for debugging android applications using Chrome desktop browser.</p><h3>What can you do using stetho ?</h3><ul><li>Analyze network traffic</li><li>Inspect elements(layouts/views)</li><li>View SQLite database in table format</li><li>Run queries on SQLite database</li><li>View shared preference and edit it</li><li>Manipulate android app from command line</li></ul><h3>Setup</h3><h4>1. Add Gradle dependency</h4><p>To add stetho in your app add ‘com.facebook.stetho:stetho:1.5.0’ dependency in your app module’s build.gradle file. This dependency is strictly required.</p><pre><strong>dependencies{<br>    compile &#39;com.facebook.stetho:stetho:1.5.0&#39;<br>}</strong></pre><p>For network inspection add one of the following dependency according to which you will be using</p><pre><strong>&#39;com.facebook.stetho:stetho-okhttp:1.5.0&#39;<br>&#39;com.facebook.stetho:stetho-okhttp3:1.5.0&#39;<br>&#39;com.facebook.stetho:stetho-urlconnection:1.5.0&#39;</strong></pre><h4>2. Initialize stetho</h4><p>Initialize stetho in class MyApplication which extends Application class by overriding <strong>onCreate()</strong> method. Make sure you have added MyAppication in manifest.</p><pre><strong>public class MyApplication extends Application {<br>    public void onCreate() {<br>        super.onCreate()<br>        Stetho.initializeWithDefaults(this);<br>    }<br>}</strong></pre><p>Stetho.initializeWithDefaults(this) initializes stetho with defaults configuration(without network inspection and more). It will be able to debug database.</p><p>Manifest file</p><pre><strong>&lt;Application   android:name=”.MyApplication”    …   /&gt;</strong></pre><p>For enabling network inspection add <strong>StethoInterceptor </strong>in OkHttpClient</p><pre><strong>new OkHttpClient.Builder()<br>    .addNetworkInterceptor(new StethoInterceptor())<br>    .build();</strong></pre><h3>Using Chrome Developer Tools</h3><h4>1. Open Inspect window</h4><h4>Run stetho initialized app on device or emulator then start Google chrome and type chrome://inspect. You will see you device with your app’s package name. Click on “inspect”</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/491/0*eEnAEfDfhF3KLskr." /></figure><h4>2. Network Inspection</h4><p>Go to <strong>Network</strong> tab. It will show all network calls. With almost all info like url(https://medium.com/path), method, returned status code, returned data type, size, time taken etc.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/660/0*pur-uw_KfyTm1Qi9." /></figure><p>You can also see preview of image and preview, response of returned json data by clicking on <strong>Name.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/660/0*HDPr6FIaoRxTnIPE." /></figure><h4>3. SQLite Database</h4><p>Go to “<strong>Resources</strong>” tab and select “<strong>Web SQL”</strong>. You will see database file(.db). By clicking on database file you will see all tables in that database file. And by clicking on table name you will see data in row-column format for that table.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/660/0*6Igb5O6jm1mOtbRX." /></figure><h4>4. Run queries on SQLite database</h4><p>Same as above go to “<strong>Resources</strong>” tab and select “<strong>Web SQL”</strong>. You will see database file(.db). By clicking on database file you will see console on right side, where you can run queries on SQLite database.</p><p>Example,</p><pre><strong>SELECT * FROM tracks ;</strong></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/660/0*KGEASN9eWNx22wSL." /></figure><h4>5. Shared Preferences Inspection</h4><p>Go to “<strong>Resources</strong>” tab and select “<strong>Local Storage</strong>”. You will show all files that your app used to save key-value pairs in shared preference and by clicking on file you will see all key-value pairs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/660/0*P5tf5UD6r-9tyZ2k." /></figure><h4>6. Element(View/Layout) Inspection</h4><p>Go to “<strong>Elements</strong>” tab. You will see top layout/view in view hierarchy. By clicking it you will see child layout/view of that layout/view. On hover on layout/view you view will be inspected in your device/emulator.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/562/0*Y75BvmmNZ9q-nx5a." /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/142/0*jbAaE9AiK2xDsfiS." /></figure><p>In this blog the most important have been put forward, but there are still some nice stuff available,like:</p><ul><li>An integration with JavaScript Console : Enables JavaScript code execution that can interact with the application</li><li>Dumpapp : It allows an integration higher than the Developer Tools, enabling the development of custom plugins.</li></ul><p>By now, you must have realized that stetho can significantly improve your debugging experience. To learn more about stetho, refer to</p><ul><li>Open source code : <a href="https://github.com/facebook/stetho">https://github.com/facebook/stetho</a></li><li>Official documentation : <a href="http://facebook.github.io/stetho/">http://facebook.github.io/stetho/</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cde8e06db916" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>