Integrating DexGuard into Android Studio

kibitzerCZ picture kibitzerCZ · Feb 27, 2015 · Viewed 8k times · Source

Has anyone of you managed to install DexGuard as a plugin to Android Studio? I am trying to do so with DexGuard 6.1 and Android Studio 1.1.0 using Settings>Plugin>Install from disk, however both libs/dexguard.jar and eclipse/com.saikoa.(...).jar files result in

"Failed to load plugin descriptor for file ((the_selected_jar))"

error.

I also attempted to do it manually (copying jars to Android Studio/plugins folder and editing gradle files), but no luck with that neither.

I could go with ProGuard, but I would like to use DexGuard for the encryptstrings function.

Answer

scottyab picture scottyab · Feb 27, 2015

I recall the for Eclipse there was a plugin, but I thought DexGuard integrates with Gradle, rather than Android Studio IDE. So there should not need to install a .jar plugin per say.

This sample from the DexGuard docs

buildscript {
    repositories {
        mavenCentral()
        flatDir { dirs '/YOUR_LOCAL_PATH_HERE/DexGuard6.1/lib' }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.0.0'
        classpath ':dexguard:'
    }
}

apply plugin: 'com.android.application'
apply plugin: 'dexguard'

android {
    .....
    buildTypes {
        debug {
            proguardFile getDefaultDexGuardFile('dexguard-debug.pro')
            proguardFile 'dexguard-project.txt'
            proguardFile 'proguard-project.txt'
        }
        release {
            proguardFile getDefaultDexGuardFile('dexguard-release.pro')
            proguardFile 'dexguard-project.txt'
            proguardFile 'proguard-project.txt'
        }
    }
}