We've been working non-stop on the Instabug for Android SDK. Today we're happy to tell you that Droid has a new friend!
When developing the SDK for Android apps we remained true to Instabug's core axiom: simplicity of integration! It's just a few steps to get the SDK working:
‍
1. Acquire the SDK
‍
For Gradle and Android Studio users, our Android SDK is published through Maven Central. All you need to do is add our dependency. If you’re still using Eclipse then don’t worry we, haven’t forgotten about you. We’ve created Eclipse projects that contain all the necessary JARs and resources to include in your application.
In your build.gradle file, add the following dependency in your dependencies block:
‍
Then click on the sync gradle files button. If you’re using the ActionBarSherlock library for implementing action bars then just replace “instabugsupport” with “instabugabs”. The versions for both artifacts are the same.
‍
To be able to support both AppCompat V7 and ActionBarSherlock we had to split our library into three components:
- Instabug Core: This contains all the core functionality of the library and is included as a dependency for the two other components
- Instabug Support: This contains all helper activities and annotation activities used with the support
- Instabug ABS: This contains all helper activities and annotation activities implemented using ActionBarSherlock activities
The SDK depends on some libraries as well:
- Android Support Library v4
- Volley
- Mime Craft
These dependencies are already defined through our Maven distribution. If you download the Eclipse SDK, you will already have the JAR files included in the downloaded project.
‍
2. Request the proper permissions
Gradle users can skip all AndroidManifest.xml instructions as these are already handled by Android plugin's manifest merger, so you can keep your own AndroidManifest.xml shorter.
‍
Next we need to request the proper permissions for the SDK to work. This is done in the AndroidManfiest.xml file. The library requires the following permissions:
‍
These are all pretty straight permissions, nothing special here.
‍
3. Define the Instabug SDK components in your AndroidManifest.xml
‍
Next, we define all required components for the SDK to work in the AndroidManifest.xml.
‍
We start with the Annotation activity. This is what will allow Android app users to draw on the screenshot and add messages that can be sent to you.
‍
Another point to note is that you have to set a theme for the annotation activity. The activity styles itself based on your Android app’s style. This allows the library to blend in with your user experience and your branding guidelines and not disrupt the user.
‍
After defining the activity, we define a service “UploadCacheService”. This service is responsible for uploading all types of reports and screenshots to our servers.
‍
We also define a broadcast receiver to receive notifications on connectivity changes. The broadcast receiver starts the UploadCacheService as soon as a network connection has been established in order to upload all cached bug/crash reports.
‍
4. Initialize the library
‍
Your Application’s class file should look something like this:
‍
This initializes the Instabug SDK, tells the SDK to show the introduction dialog when an activity of type MyFirstContentActivity is started for the first time. It also enables the e-mail field in the feedback dialog form but specifies that it isn’t required. Finally, it sets the enable overflow menu item flag so that an item is added to the action bar overflow menu with “Send Feedback”.
‍
There are many other customization options and we recommend you go through them in the library’s documentation page.
‍
5. Register your activities with Instabug
‍
This is the final step before you can start receiving bugs in your dashboard. If you’re minSdkVersion 14, you don’t really need to do this step as we can automatically detect activity life cycles. However, for SDK levels less than 14, we need to keep track of the displayed activity. We’ve already created helper activity classes, so you don’t need to worry about any of that. All you have to do is just extend them.
- InstabugActionBarActivity : This extends android.support.v7.app.ActionBarActivity
- InstabugActivity : This extends android.app.Activity
- InstabugFragmentActivity : This extends android.support.v4.app.FragmentActivity
- InstabugExpandableListActivity : This extends android.app.ExpandableListActivity
- InstabugListActivity : This extends android.app.ListActivity
- InstabugPreferenceActivity : This extends android.preference.PreferenceActivity
‍
These helper activities also contain helper code to make certain features of the SDK work, including things like the two finger swipe gesture invocation. If, for some reason, you're unable to extend our Activity classes, you can add the following code to your Activity to register it with our SDK:
‍
Another benefit of using our base activity helpers is automatic user step detection. This allows us to send you with every bug report the detailed log of step-by-step user actions. However, if you can’t extend our base activities then no problem, you can do this yourself using our TouchEventDispatcher class. All you have to do is add the following code in your base activity:
‍
Congratulations! You have now successfully integrated the Instabug SDK for Android apps. It's time to get shaking and start fixing those nasty bugs!
If you have any questions please feel free to e-mail us at contactus@instabug.com.