Skip to main content

Installation

Learn how to add Shake to your Android app using Gradle.

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, 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>

Build and run your project by selecting Run β†’ Run in the menu bar. This first run will automatically add your app to your Shake dashboard based on your app bundle ID.

Conditional initialization

We recommend initializing Shake in the entry point of your app. However, depending on your app, you'll want to initialize Shake just in a specific conditions, depending on your app data. You can do it as shown in the example below when your app data is available:

MainActivity.kt
class MainActivity : Activity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
if (User.isTester) {
Shake.start(this, "your-api-client-id", "your-api-client-secret")
}
}
}
note

If you are initializing Shake outside Application class, make sure you initialize it in the onCreate callback of the Activity.

Visit your Shake dashboard

Follow the instructions there to send your first feedback with Shake and you're all set.

SDK customizations

Now that Shake SDK is in your app and you have sent the first feedback for fun, everything else is optional. As the next step, try the three most popular SDK customizations: