Heap Gradle Plugin
Requirements + Known Limitations
The Heap Gradle Plugin:
- Is hosted through Maven Central.
- Supports version 0.1.0 and higher of the Heap Android View Autocapture SDK.
- Supports version 1.10.5 and higher of the legacy Heap Android Client SDK.
- Requires version 7.2 or higher of the Android Gradle Plugin.
- Is fully compatible with Android Gradle Plugin 8.0.
Plugin Installation
Modern Gradle Plugin Syntax
- Verify that your project is set up to retrieve plugins and dependencies from Maven Central. Android Studio will likely have configured your project in this way when you created it. To verify, make sure the
pluginManagement.repositoriesblock anddependencyResolutionManagement.repositoriesblock in your project’ssettings.gradlefile (orsettings.gradle.ktsfile) both callmavenCentral()like so:
pluginManagement {
repositories {
...
mavenCentral()
}
}
dependencyResolutionManagement {
repositories {
...
mavenCentral()
}
...
}
pluginManagement {
repositories {
...
mavenCentral()
}
}
dependencyResolutionManagement {
repositories {
...
mavenCentral()
}
...
}
- At the top of your application module’s
build.gradlefile (not the project’sbuild.gradlefile), pull in theio.heap.gradleplugin as shown below.
This has to come after the
com.android.applicationplugin has been applied.
plugins {
id 'com.android.application'
...
id 'io.heap.gradle' version '0.3.+'
}
plugins {
id("com.android.application")
...
id("io.heap.gradle") version "0.1.+"
}
Legacy Gradle Plugin Syntax
If you are using legacy Gradle plugin syntax to pull in Android’s build tools, you'll need to integrate the Heap Android Gradle Plugin in the following manner:
- In your project’s
build.gradlefile, configure yourbuildscriptblock to use Maven Central as one of its repositories and add the Heap plugin to the class path:
pluginManagement {
...
}
buildscript {
repositories {
...
mavenCentral()
}
dependencies {
...
classpath 'io.heap.gradle:heap-plugin:0.3.+'
}
}
- In your application module’s
build.gradlefile (not the project’sbuild.gradle) file, apply theio.heap.gradleplugin as shown below.
This has to come after the
com.android.applicationplugin has been applied.
...
apply plugin: 'com.android.application'
apply plugin: 'io.heap.gradle'
Dependency Installation
- In the
dependenciesblock of your application module’sbuild.gradlefile, add the desired Heap autocapture SDK as an implementation dependency:
dependencies {
...
// NOTE: Only add one of these depending on your desired install path.
// Heap Android View Autocapture SDK
implementation 'io.heap.autocapture:heap-autocapture-view:0.3.+'
// Legacy Heap Android SDK
implementation 'com.heapanalytics.android:heap-android-client:1.10.+'
}
dependencies {
...
// NOTE: Only add one of these depending on your desired install path.
// Heap Android View Autocapture SDK
implementation("io.heap.autocapture:heap-autocapture-view:0.1.+")
// Legacy Heap Android SDK
implementation("com.heapanalytics.android:heap-android-client:1.10.+")
}
- Complete the instructions in the Initializing Heap section.
- Build your app!
Initializing Heap
To use Heap on Android, you need to initialize the installed Heap SDK. Please consult the SDK-specific docs for instructions on how to initialize Heap.
Configuration
The Heap Gradle Plugin supports optional extension properties to customize instrumentation behavior and certain capture behaviors. These extension properties can be defined in your application module’s build.gradle file by including an ext block in defaultConfig or in any of your applications build types or product flavors. The table below defines the support extension properties.
All property names are case sensitive.
| Property | Type | Default | Description |
|---|---|---|---|
heapAutoInit | Boolean | false | Boolean setting to enable initialization configuration at build time. If this is false, you must initialize Heap programmatically.If this is true, you must also set heapEnvId to a stringified 53-bit integer. |
heapCaptureAdvertiserId | Boolean | false | Boolean setting to enable Advertiser ID capture. |
heapCaptureAndroidId | Boolean | false | Boolean setting to enable Android ID capture. |
heapDisableTextCapture | Boolean | false | Boolean setting to disable text capture on views. |
heapEnabled | Boolean | true | Boolean setting to enable build-time instrumentation for autocapture. If this is set to false, UI interactions will not be autocaptured. |
heapEnvId | String | null | The Environment ID to use for initialization configuration at build time. This setting only takes effect if heapAutoInit is set to true. It must be set to the 53-bit stringified integer Env ID that you wish to send data to.Setting heapEnvId to an invalid or empty string when heapAutoInit is set to true will result in Heap failing to initialize at run-time. Likewise, failure to set heapEnvId or setting heapEnvId to null when heapAutoInit is true will result in Heap failing to initialize at run-time. |
Changes from Legacy Instrumentor (heap-android-gradle)
heapEnableddefaults to true for the Heap Gradle Plugin. The legacy plugin (heap-android-gradle) defaults tofalse.heapCaptureAdvertiserIdonly takes effect ifheapAutoInitis set totruefor the Heap View Autocapture SDK. The legacy autocapture SDK would apply the advertiser ID setting without respect to theheapAutoInitsetting. (The new core SDK has affordances to enable/disable advertiser ID capture for programmatic initialization.)
Updated almost 2 years ago