auspicious99
auspicious99

Reputation: 4321

proguardFile getDefaultDexGuardFile('dexguard-release.pro') no longer works

When using DexGuard with android studio, there's a line we have always needed to include for our release builds, and that's

proguardFile getDefaultDexGuardFile('dexguard-release.pro')

I have never been able to figure out how to change the path that getDefaultDexGuardFile looks in for dexguard-release.pro, but so far it has always been correctly searching in the /lib folder of my DexGuard folder.

Even 2 days ago, with Android Studio 2.0.0 it was fine. Today, I tried building the release version of another project, where it had found dexguard-release.pro before (with Android Studio 1.5.0 earlier on), and now it gives

Warning:Exception while processing task java.io.FileNotFoundException: /lib/dexguard-release.pro (No such file or directory)

How am I supposed to fix this? There appears to be no documentation through google search (or the official DexGuard docs) that explain the workings of getDefaultDexGuardFile .. how it decides where to look, or how to change it. Furthermore, the warning message is not very helpful, giving what appears to be a partial path /lib/dexguard-release.pro rather than the full path of the actual place it is now trying to find dexguard-release.pro

If somebody could tell me how I could gain some control of the path that getDefaultDexGuardFile is searching .. ?

Upvotes: 1

Views: 3439

Answers (1)

Tomik
Tomik

Reputation: 23977

First make sure you have all the necessary settings for DexGuard.

Using DexGuard in Gradle requires buildscript settings in build.gradle file:

buildscript {
    repositories {
        …
        // use your path to DexGuard library
        flatDir { dirs '/usr/local/DexGuard-7.1.02/lib' }
    }
    dependencies {
        …
        classpath ':dexguard:'
    }
}

And then apply DexGuard plugin:

apply plugin: 'dexguard'

If the settings are fine and you are still having problems with getDefaultDexGuardFile() method. You can do a quick fix - ignore the method and copy DexGuard config files from the location of DexGuard library directly into your project and reference them directly. But note that the config files might be referencing other files so you would have to copy them too.

Also check that your license for DexGuard is valid.

And it might also be that DexGuard is not currently compatible with the Gradle version you use or the version Android build plugin. I guess they were recently still supporting Gradle 2.2, and recent update of Android Studio was trying to update it to 2.10 to enable Instant Run (and similar situation is with Android plugin).

Upvotes: 2

Related Questions