Install Shake

This page describes how to install the Shake SDK into your Android application via Gradle. Whether you are using Java or Kotlin, you can follow the steps below.

Add Shake dependency to your app-level build.gradle file

build.gradle
dependencies {
implementation 'com.shakebugs:shake:'
}

Set compileSdkVersion version in the build.gradle file

Since Shake requires compileSdkVersion 29 or greater, verify that compileSdkVersion is correctly set in the app build.gradle file.

build.gradle
android {
compileSdkVersion 30
defaultConfig {
applicationId "com.example"
minSdkVersion 21
targetSdkVersion 30
versionCode 1
versionName "1.0.0"
testInstrumentationRunner "androidx.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
}

Initialize Shake

Initialize Shake in the onCreate callback of your Application. Replace your-api-client-id and your-api-client-secret with the actual values you have in your workspace settings.

App.kt
import android.app.Application
import com.shakebugs.shake.Shake
class App : Application() {
override fun onCreate() {
super.onCreate()
Shake.start(this, "your-api-client-id", "your-api-client-secret")
}
}

If you’re creating a custom Application class for the first time, make sure to specify it in your AndroidManifest.xml:

AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application
android:name=".App">
</application>
</manifest>
note

We recommend initializing Shake in the Application class, but sometimes you'll want to initialize Shake after the app is started, depending on the data retrieved from the backend. You can use Shake.start() method in the Activity, just make sure to call it in the onCreate callback of the Activity.

Now build your project and see everything work! To build and run your app, select Run › Run in the menu bar. This first run will automatically add your app to your Shake Dashboard based on your app bundle ID.