Debugging in Android with Robin, Logging essential data

Bal sikandar
MindOrks
Published in
3 min readMay 29, 2018
Image from piktochart

If you’re an Android developer then one of the thing that you commonly use is Bundle. Bundles are the coolie of Android platform, They carry the data and pass among components and hence provide the communication mechanism, So each component can work independently by putting there trust on bundle that they’ll do the job💥. But sometimes their delivery is either late or there is no delivery at all.

And then developers get active okay something is wrong let’s see, first we’ll grab a coffee, then we’ll go to washroom, then we’ll look at code a little and finally attach a debugger to see what’s taking so long only to find OH! 😮. That’s why i created Robin.

Bundles

Definition: A mapping from String values to various Parcelable types. Bundle is generally used for passing data between various activities of android. You can create an Intent and attach a bundle to it. Bundle is with us from day one, i.e API level-1 and it’s still kicking. Coming back to robin.

Robin is a small utility library to log Bundle data passed between Activities and fragments along with few other features.

Robin in Action

  • Logs Bundle data passed among Activity/Fragments.
  • Callback to get screenViews in one place.
  • Callback to add bread crumbs to Crashlytics to retrace user action before crash.
  • API to transform Bundle to HashMap.

Let me tell you how it works. Just add below dependency in your app’s gradle. Use debugCompile for debug only use.

compile 'com.balsikandar.android:robin:0.1.2'

Then initialise it in your Application class using.

Robin.start(this)

Now you can use Robin in your logcat to filter the bundle data

from robin sample app

Other moves of Robin

  • Tracking screen views in application class
  • Interface for Activity/Fragment lifecycle callbacks which can be logged to crashlytics to track user actions. Check my previous article about Crashlytics.
  • An API to transform bundle data to HashMap

You can implement ScreenViewCallback callback in you application class which provides

@Override
public void onScreenShown(String className, String customLabel){

}

className: is actual name of Activity/Fragment class which in most cases isn’t the right choice to log on analytics platforms. So, Define a global variable named screenView in your Activity/Fragment classes with your own values like.

private String screenView = "RobinSampleHomePage";

And it’ll be returned in onScreenShown callback as customLabel.

You can implement LifeCycleCallbacks in your application class which provides

@Override
public void breadCrumps(String className, String callback) {

}

className: is Activity/Fragment class name, callback: is lifecycle callback method name. It can be used to track user actions before any crash.

Why? In 3–4 % of cases, Stacktrace on Crashlytics is unable to provide the cause of the crash. We can’t even determine when and where it happened. For that reason above callback can be very useful. I myself use this in all my projects.

To know more about Robin check below link

This library is in it’s infant phase with more to come. Fo any feature suggestion or question raise a ticket here. Cheers!!!

To be continued…

Thanks for reading this article. Be sure to click 👏 to recommend this article if you found it helpful. It means a lot to me.

For detailed queries check out this Github repo. Sayonara :)

Check all the top articles at blog.mindorks.com

Also let’s connect on facebook, twitter, github and linkedin.

Clap, share if you like it and follow me for the updates.

--

--

Bal sikandar
MindOrks

Android developer @shuttl Ex @_okcredit. Blogger | Open source contributor https://about.me/balsikandar.