Setup (Android)

Reaper is an SDK that uses production data for detecting dead code. See the emerge-android repo for more information.

Quick setup

Install the SDK

First, if you haven't already, you must install our Gradle plugin by following our setup guide. The Gradle plugin is used to instrument your application code.

Second, add an implementation dependency for the Reaper SDK:

Latest version: Maven Central

// app-module build.gradle.kts
dependencies {  
  implementation("com.emergetools.reaper:reaper:<latest_version>")
}

Configure the SDK

The SDK is what automatically sends dynamic analysis user sessions to our API. To send sessions we need to configure two settings within the reaper block: enabled and publishableApiKey.

  • enabled is a boolean property which controls whether the plugin instruments the bytecode during compilation.
  • publishableApiKey is a token included with reports uploaded from the field to Emergetools.
// app-module build.gradle.kts
plugins {
  id("com.emergetools.android")
}

emerge {
  // ...snip...
  
  reaper {
    enabled.set(true)
    publishableApiKey.set("<PUBLISHABLE API KEY>")
  }
}

Upload an .aab build

This is done automatically by the ./gradlew :<app>:emergeInitializeReaper<variant> Gradle task. Alternatively, you can manually upload the .aab via the https://www.emergetools.com/uploads UI.

📘

Setup verification

Running the ./gradlew :<app>:emergeInitializeReaper<variant> Gradle task will notify you of any failing steps.

Manual initialization

By default Reaper uses the Jetpack startup library to automatically initialize itself however you may need to manually initialize Reaper. To manually initialize Reaper call Reaper.init(context). For example:

import com.emergetools.reaper.Reaper

class MyApp : Application() {
  override fun onCreate() {
    Reaper.init(this)
  }
}
import com.emergetools.reaper.Reaper;

public class MyApp extends Application {
  @Override
  public void onCreate() {
    super.onCreate();
    Reaper.init(this);
  }
}

A common case when manual initialization is required is when androidx.startup.InitializationProvider has been globally disabled by the following snippet being included in the AndroidManifest.xml:

<provider
    android:name="androidx.startup.InitializationProvider"
    android:authorities="${applicationId}.androidx-startup"
    android:exported="false"
    tools:node="remove">
  <meta-data
    	android:name="androidx.work.WorkManagerInitializer"
    	android:value="androidx.startup"
    	tools:node="remove" />
</provider>