July 1, 2018

    Setting up DexGuard in Android Studio

    Setting up DexGuard in Android Studio is straightforward. DexGuard comes with its own Android Studio plugin that is continuously kept up-to-date. Adding it to your project is easy and allows for a transparent integration with your build.

    Integrating DexGuard in your Android project

     First, you have to download DexGuard and your license file from your dashboard on our website. Don't forget to place the license file in your home directory (DexGuard can be configured to use other locations).

    Once that is done, you need to add four elements to your build.gradle file to integrate DexGuard into your Android project.

    1. The path to the dexguard.jar file you downloaded from your account. It’s defined as a flatDir:
      buildscript {
        repositories {
          flatDir { dirs '../../../lib' } // For the DexGuard plugin.
        }
        ...
      }
      
    2. The dependency on DexGuard for documentation for your build script. It’s defined as a classpath:
      buildscript {
        ...
        dependencies {
          classpath ‘:dexguard:’
        }
      }
    3. The definition of the plugin. It goes by the suitable name ‘dexguard’:
      apply-plugin: ‘dexguard’
    4. The new default DexGuard Android configuration files that are included in your DexGuard download:
      android {
        buildTypes {
          debug {
            proguardFile getDefaultDexGuardFile('dexguard-debug.pro') } release {
            proguardFile getDefaultDexGuardFile('dexguard-release.pro') } } } 

    After these four elements have been added to your build.gradle file, you need to remove all ProGuard-related Gradle options from your buildtype configurations. This includes minifyenabled, multidexenabled and shrinkresources. The DexGuard Android plugin takes over all of these functionalities.

    Configuring DexGuard for Android

    The next step is to configure DexGuard. The actual configuration will depend on your code base and on your security requirements.

    DexGuard provides the following features to help you out during this phase:

    - DexGuard is fully compatible with ProGuard. You can re-use your existing ProGuard configuration   and add rules for the advanced functionality DexGuard provides.

    - DexGuard comes with a plugin for Android studio that performs auto-completion in configuration files. To install it, go to your Android Studio Preferences > Plugins and click “Install plugin from disk…”. Browse to the studio folder in your DexGuard download and double-click to install.

    - DexGuard includes optimized configuration for popular frameworks such as Crashlytics, Firebase, Dagger, okHttp etc. (We recommend removing any ProGuard configuration rules related to any of these frameworks.)

    Connect with an expert for a full DexGuard Android tutorial, and to learn more about the comprehensive mobile app protection offered.

    Guardsquare

    DexGuard protects Android apps & SDKs against analysis and attacks, with multiple hardening techniques & RASP

    Download Fact Sheet >

    Other posts you might be interested in