Integrating Instabug for Android
This page covers how to install the Instabug SDK in your Android application.
Compile SDK Version
Please note that the
compileSDKVersion
should be v29 or above, otherwise you may run into build errors.
Installation
This installation process will install the Instabug SDK that supports Bug Reporting, Crash Reporting and App Performance Monitoring.
Gradle
Add this line to your build.gradle
file.
implementation 'com.instabug.library:instabug:14.0.0'
Maven
<dependency>
<groupId>com.instabug.library</groupId>
<artifactId>instabug</artifactId>
<version>14.0.0</version>
</dependency>
Using Instabug
In your Application
class add this line to your onCreate
method. This initializes Instabug with the default invocation event, Shake.
Instabug.Builder(this, "APP_TOKEN").build()
new Instabug.Builder(this, "APP_TOKEN").build();
Initializing Instabug in your application can also be done using one or multiple invocation events. All possible invocation events are explained in the invocation section.
Instabug.Builder(this, "APP_TOKEN")
.setInvocationEvents(InstabugInvocationEvent.SHAKE, InstabugInvocationEvent.FLOATING_BUTTON)
.build()
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 menu of your Instabug dashboard.
Permissions
Permissions are automatically added to your AndroidManifest.xml
file. Some of them are required to be able to fetch information like network and WiFi connection. Others are used to allow your users to attach images, videos, and audio recordings. In general, permission requests don't appear unless your user attempts to use a feature requiring a permission.
The only exception is if you set the invocation event to be a Screenshot. In that case, the storage permission will be requested when your application launches. The screenshot invocation is a special case because there is no native event that tells the SDK that a screenshot has been captured. The only way to know is to monitor the screenshots directory. The SDK is invoked when a screenshot is added to the directory while your 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” />
<uses-permission android:name=“android.permission.INTERNET” />
<uses-permission android:name=“android.permission.WAKE_LOCK” />
You can remove any of the permissions if you will not be using the feature associated with it, as in the following example.
<uses-permission android:name=“android.permission.WRITE_EXTERNAL_STORAGE” tools:node=“remove”/>
Required Permissions
There are a few permissions that are always required and cannot be removed. These permissions are:
<uses-permission android:name=“android.permission.WAKE_LOCK”/>
<uses-permission android:name=“android.permission.INTERNET”/>
Updated 6 days ago
Now that you've successfully integrated Instabug, check out how to show Instabug using different methods, how to identify your users, and how to customize the SDK.