PreEmptive Protection - DashO v8.2 User Guide

Migrating from Eclipse (Ant) to Android Studio (Gradle)

Google has released a new build system and recommends moving away from Eclipse and the Ant-based tools. There are three main parts to this migration: changing over to the new IDE, updating the PreEmptive Protection - DashO project, and integrating it into the new Gradle-based build. These instructions are based on Android Studio v1.0.1 and Eclipse ADT Plugin v23.0.2, but should apply to most other versions.

IDE Migration

Follow the instructions at to migrate to the new IDE. You can either have the ADT plugin generate a Gradle build script or allow Android Studio to import and convert the Eclipse project. Depending on how you migrate, Android Studio may mention that the project is using an unsupported version of the Android Gradle Plugin. If so, go ahead and update it. Once the project is setup, verify it builds and runs properly from Android Studio before continuing.

PreEmptive Protection - DashO Project Update

A project.dox file was created when you originally used DashO’s Android Ant wizard. If you did not create this configuration using the wizard, you can still follow these instructions, but some of the values may be different. Here are the steps:

  1. Open project.dox in DashO

  2. On the Input page, change ${out.classes.dir} to ${gradleInput}.

  3. On the Input->Support page, change ${sdk.dir}\platforms\android-${target}\android.jar to ${sdk.dir}\platforms${}\android.jar.

  4. On that same page, create a new entry of ${gradleSupport:-}.

  5. On the Input->Non-Class Files page create a new entry with a source of ${AndroidManifestFile} and a destination of ${AndroidManifestOutput}.

  6. On the Output page, change ${dasho.results.jar} to ${gradleOutput}.

  7. Save project.dox.

The above changes are the minimum required to integrate with DashO’s Gradle Plugin. However, if you would like to test your project from inside DashO, you will need to set default values for the User Properties used above. Go to the Properties page and make the following changes:

  • Delete the out.classes.dir property.

  • Delete the dasho.results.jar property.

  • Delete the target property.

  • Change the value of to android-?? (where ?? is the number it had before).

  • Change the value of dasho.results.dir to ${build.dir}/dasho-results/${buildType}.

  • Add a build.dir property with a value of build.

  • Add a buildType property with a value of debug.

  • Add a gradleInput property with a value of ${build.dir}/intermediates/classes/${buildType}.

  • Add a gradleSupport property with a blank value.

  • Add a gradleOutput property with a value of ${build.dir}/dasho/${buildType}/classes.jar.

  • Add an AndroidManifestFile property with a value of ${build.dir}/intermediates/manifests/full/${buildType}/AndroidManifest.xml.

  • Add an AndroidManifestOutput property with a value of ../../../intermediates/manifests/full/dasho-${buildType}.


The path values above may need to be tweaked for your individual build environment.

Gradle Integration

Depending on how you migrated to the new IDE, you may have one or two build.gradle files. If Android Studio created a copy of the Eclipse project, you will probably have one build.gradle at the root and another in an application subdirectory. If you have two files, make sure you are manipulating the correct one at the appropriate times as described below.

There are two steps to integrate DashO into a Gradle build: adding the plugin and then configuring it.

Find the build.gradle file which contains a section like this:

buildscript {
    repositories {
        jcenter() //or mavenCentral()
    dependencies {
        classpath '{x.y.z}'

Above jcenter() add a line with flatDir dirs: "{DashO's Installation Directory}/gradle" inside the repositories section, changing {DashO's Installation Directory} to the path where DashO is installed. Use forward slashes to separate the folders.

Above the classpath entry for '{x.y.z}' add a line with classpath "com.preemptive:dasho:{x.y}.+" inside the dependencies section. Make sure to use the correct version of the DashO Gradle plugin. See the Version Compatibility section of the DashO Gradle Plugin User Guide.

Find the build.gradle file which contains apply: '' or apply: 'android'. Below the apply: line add a line with apply from: 'dasho.gradle'.

Make sure the project.dox file is located in the same directory as this build.gradle file. Create a file named dasho.gradle, in this same directory, with the following contents:

dashOConfig {
    dashOHome = '{DashO's Installation Directory}'
    doxFilename = 'project.dox'

Again, changing {DashO's Installation Directory} to the path where DashO is installed.

If this directory contains a file named AndroidManifest_pre_ob.xml, delete it. This file is used with the Ant integration and will cause issues with the Gradle integration.

You should now be able to build your project with DashO either via the command line or via Android Studio.


Please see consult the Android Gradle Plugin User Guide and DashO Gradle Plugin User Guide for additional information.

Integration Differences

There are some differences between Ant and Gradle environments. The Ant script is not used when compiling inside Eclipse, while the Gradle script is used when compiling inside Android Studio. The Ant script blindly recompiles code while the Gradle script can determine which steps need to be performed. There are also a few differences on how they are integrated with DashO.

In the Ant-based integration, DashO runs when explicitly included on the command line (E.G. ant obfuscate debug vs. ant debug). With Gradle, DashO always runs based on how it is configure in the dasho.gradle file. If, for example, you would like to not run DashO during a debug build, you can add the following inside the dashOConfig section of dasho.gradle:

disabledForBuildTypes = ['debug']

The Ant-based integration automatically configures DashO to not remove debug information from classes when running a debug build vs. always removing them during a release build. This is still possible via the Gradle integration but it works a bit differently. The DashO Gradle plugin can determine which .dox file to use based on the build type, when no dox file is configured in the dashOConfig section of dasho.gradle. You could remove the doxFilename setting and create a debug.dox file which is configured to keep the debug information and then a release.dox file which is configured to remove it. You would then however need to make sure any other configuration changes are kept in sync between these two files.

It was possible, in the Ant integration, to manipulate the configuration in the .dox file or define the configuration entirely within your Ant script. This functionality is not available in the Gradle integration.

PreEmptive Protection - DashO Version 8.2.0. Copyright © 2017 PreEmptive Solutions, LLC