Updated 28 June 2017
We all know how to view the source code of any web page or inspect element and other stuff on any browser. This can be done using any browser even Internet Explorer 4 can do that. But what’s new. Just like Android Studio, Chrome is my personal favorite even though both of them combined eats up system ram heavily. Chrome is a powerful tool because of a lot of powerful Chrome apps and developer tools are available and supported.
In this blog, we are going to find out some of the cool features of using Chrome in respect to Android application debugging/inspecting.
One such feature is remote debugging Android devices via chrome developer tools.
If you knows web developement, I am sure your website contains mobile friendly web pages. But there are times when loading your site on mobile doesn’t look or behave as expected. Thus you need a developer tool for mobile as well just like chrome developer tool for website or firebug if in case you are an FireFox lover.
We can do the same for web pages loading on Android devices using Chrome application.
Remote Debugging benefits
There are some requirements to perform remote debugging smoothly viz,
For further reading: Click here
Chrome Developer Tools only enable debugging for chrome app and web views. For debugging your Android application we can use debug bridge like stetho which provide access to the Chrome Developer Tools feature for your application.
Add Stetho dependency in module level gradle
1 compile 'com.facebook.stetho:stetho:1.5.0'
In case you are using okhttp3 network library then to log request and response we can use the following dependency:
1 |
compile 'com.facebook.stetho:stetho-okhttp3:1.5.0' |
For other, Check here
Update application class to initialize stetho with defaults:
1 2 3 4 5 6 7 |
public class MobikulApplication extends Application { @Override public void onCreate() { super.onCreate(); Stetho.initializeWithDefaults(this); // add this line } } |
Enable network inspection:
1 2 3 |
new OkHttpClient.Builder() .addNetworkInterceptor(new StethoInterceptor()) .build() |
On Adding stetho interceptor in your application’s okhttp client you can modify request/response and monitor it accurately. Now we are ready to inspect and debug Application.
Once done with the set-up instructions, just start your app and point your development machine browser to chrome://inspect
. Click the “Inspect” button to begin.
If you have more details or questions, you can reply to the received confirmation email.
Back to Home
Be the first to comment.