DESK Gradle plugin for Android app auto-instrumentation

The DESK Gradle plugin does not support the instrumentation of Android App Bundles.

The DESK Gradle plugin is based on the Android Gradle plugin. The DESK Gradle plugin inserts auto-instrumentation at the end of the Android build task sequence. Auto-instrumentation gets triggered by the Android build process and instruments your newly build APK file. The instrumented APK file is also automatically signed with the specified certificate. The DESK Gradle plugin stores the instrumented and signed APK file under the same name in the same location (<project>/<module>/build/outputs/apk/<productFlavor>/<buildType>/<app_name>.apk). The advantage of this approach is that the Run button from the Android Studio can use the instrumented APK file and can install it on your device/emulator.

Supported Android Gradle plugin versions

The DESK Gradle plugin is hosted on JCenter and Maven Central. For details on DESK Gradle plugin version and Android Gradle plugin version interoperability, please see supported Android Gradle plugin versions.

Run auto-instrumentation using DESK Gradle plugin

To run auto-instrumentation using DESK Gradle plugin:

Click Applications in the navigation menu.

Select your mobile application.

Click the browse button (...) in the top right corner and select Edit.

Click Instrumentation in the left menu.

Select Google Android.

Select the Gradle tab. In this tab, you will find the following Gradle snippet that is already populated with the configuration values from your mobile app:

buildscript {
repositories {
  jcenter()
  }
  dependencies {
   classpath 'com.desk.tools:android:7.+'
  }
}

apply plugin: 'com.desk.tools.android'
desk {
 defaultConfig {
   applicationId '<YourApplicationID>'
   beaconURL '<ProvidedBeaconURL>'
 }
}

Alternatively, you can deactivate the auto-start injection feature from the auto-instrumentor with the DTXAutoStart property. In this case you don't need to specify the DTXApplicationID and the DTXBeaconURL properties, because you have to specify these values in the manual startup call. You have to add the startup call manually into the Application.onCreate method and load the auto-instrumentation configuration with the DESKConfigurationBuilder.loadDefaultProperties(Context) method. For more information, see the OneAgent SDK for Mobile section.

DESK.startup(this, new DESKConfigurationBuilder("YourApplicationID", "ProvidedBeaconURL")
	.loadDefaultProperties(context)
	...
	.buildConfiguration());

Copy this Gradle snippet into your module's build.gradle file and the DESK Gradle plugin will automatically instrument your mobile app on every build. Of course, if you are familiar with Gradle, you can customize the Gradle snippet. In this case, you have to ensure that the DESK Gradle plugin dependency is added to your build script. Additionally, the apply statement and the desk extension block must be added to the same build.gradle file that also contains the apply statement of the Android Gradle plugin.

You can optionally perform additional configuration.

Start your next build.

Signing

The DESK Gradle plugin uses the signing configuration and logic from the Android Gradle plugin. You don't have to add any additional settings to the DESK Gradle plugin.

android {
    ...
    defaultConfig {  }
    signingConfigs {
        release {
            storeFile file("my-release-key.jks")
            storePassword "password"
            keyAlias "my-alias"
            keyPassword "password"
        }
    }
    buildTypes {
        release {
            signingConfig signingConfigs.release
            ...
        }
    }
}

Limitations

  • Do NOT use whitespaces in your project path.
  • Do NOT use the Android Studio feature Instant Run. With Android Studio version 2 and later, Android introduced the new feature Instant Run. This feature significantly reduces the app update time. The DESK Gradle plugin for Android does not support Instant Run APKs and the corresponding Gradle build process. You should disable the Instant Run setting. To do this, open the Settings and navigate to Build, Execution, Deployment > Instant Run. Then clear the Enable Instant Run check box.
  • The APK Signature Scheme v3 is currently not supported.

See the auto-instrumentation limitations for more information.