Integration

This page covers how to install the Instabug SDK into your Android application.

Installation

Below are the ways you can use to add Instabug to your project so you can start squashing bugs.

Gradle

Add this line to your build.gradle file.

implementation 'com.instabug.library:instabug:8+'

Maven

<dependency>
      <groupId>com.instabug.library</groupId>
      <artifactId>instabug</artifactId>
      <version>8+</version>
</dependency>

Using Instabug

In your Application class add this line to your onCreate method. This initializes Instabug with the default invocation event; Shake.

new Instabug.Builder(this, "APP_TOKEN").build();

Initializing Instabug in your application could also be done using one or multiple invocation events. All the invocation events are stated in the invocation section.

new Instabug.Builder(this, "APP_TOKEN")
	.setInvocationEvents(InstabugInvocationEvent.SHAKE, InstabugInvocationEvent.SCREENSHOT)
	.build();

You can find your app token by selecting SDK Integration in the settings popup from your Instabug dashboard.

Permissions

Some permissions are automatically added to your AndroidManifest.xml file. Some of them are required to be able to fetch some information like the network and WiFi connection. Others are used to allow the user to attach images, videos, and audio recordings.

Generally, the permission request doesn't appear unless the user attempts to use any of the features requiring the permission. The only exception, if you set the invocation event to be Screenshot. Then, the storage permission will be requested when the application launches.

This behavior is happening with the screenshot invocation because there isn't any native event that tells the SDK that a screenshot has been captured. The only way to do it is to monitor the screenshots directory. The SDK is invoked once a screenshot is added to the directory while the application is active.

<uses-permission android:name=“android.permission.ACCESS_NETWORK_STATE” />
<uses-permission android:name=“android.permission.WRITE_EXTERNAL_STORAGE” />
<uses-permission android:name=“android.permission.READ_EXTERNAL_STORAGE” />
<uses-permission android:name=“android.permission.ACCESS_WIFI_STATE” />
<uses-permission android:name=“android.permission.RECORD_AUDIO” />
<uses-permission android:name=“android.permission.MODIFY_AUDIO_SETTINGS” />

You can remove any of the permissions if you are not willing to use the feature associated with it as in the following example.

<uses-permission android:name=“android.permission.WRITE_EXTERNAL_STORAGE” tools:node=“remove”/>