5

I am having a bit of trouble trying to integrate dexguard to my android/gradle project.

  • Dexguard: 5.5.32
  • gradle: 2.2.1
  • gradle-plugin: 1.3.0
  • buildToolsVersion: 23.0.1

I get the following error when I apply plugin: 'dexguard':

Error:Unable to load class 'com.android.builder.SdkParser'

EDIT:

Here is my app's gradle file:

buildscript {
    repositories {
        flatDir { dirs '/usr/local/DexGuard5.5.32/lib' }
        jcenter()
    }
    dependencies {
        classpath ':dexguard:'
        classpath 'com.android.tools.build:gradle:1.3.0'
    }
}

apply plugin: 'com.android.application'
apply plugin: 'dexguard' //This, when uncommented produces the error

dependencies {
    compile fileTree(dir: 'libs', include: '*.jar')
    compile files('libs/commons-collections4-4.0.jar')
    compile files('libs/commons-codec-1.10.jar')
    compile files('libs/gson-2.3.1.jar')
    compile files('libs/jaxb2-maven-plugin:2.1.jar')
    compile project(':sdk')
    compile project(':zxing-lib')
}

android {
    signingConfigs {
        release {
            //my signing config
        }
    }
    compileSdkVersion 22
    buildToolsVersion '23.0.1'
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }
    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src/main/java', 'src/main/native', 'src/test/java']
            resources.srcDirs = ['src/main/java', 'src/main/native', 'src/test/java']
            aidl.srcDirs = ['src/main/java', 'src/main/native', 'src/test/java']
            renderscript.srcDirs = ['src/main/java', 'src/main/native', 'src/test/java']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
        }

        // Move the tests to tests/java, tests/res, etc...
        instrumentTest.setRoot('tests')
    }
    packagingOptions {
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
    }
    buildTypes {
//The following should be uncommented when dexuard works!!!
//        debug {
//            proguardFile plugin.getDefaultDexGuardFile('dexguard-debug.pro')
//            proguardFile 'dexguard-project.txt'
//            proguardFile 'dexguard-project-debug.txt'
//            proguardFile 'proguard-project.txt'
//        }
//        release {
//            proguardFile plugin.getDefaultDexGuardFile('dexguard-release.pro')
//            proguardFile 'dexguard-project.txt'
//            proguardFile 'dexguard-project-release.txt'
//            proguardFile 'proguard-project.txt'
//        }
    }
    allprojects {
        gradle.projectsEvaluated {
            tasks.withType(JavaCompile) {
                options.compilerArgs << "-Xlint:deprecation"
            }
        }
    }
    defaultConfig {
        targetSdkVersion 22
        signingConfig signingConfigs.release
    }
    productFlavors {

        app2 {
            applicationId "some.app.id"
        }
        app {
            applicationId "some.app.id2"
        }
    }
}

What are your thoughts ??

Moumou
  • 1,513
  • 2
  • 18
  • 41
  • Posting your gradle file might help as well. – Sharjeel Oct 11 '15 at 20:55
  • Please, Please. Start by updating everything. 1) Gradle 2.7 is out. 2) Gradle-plugin 1.3.1 is out. 3) Convert all dependencies to Gradle, not jars 4) Convert your eclipse sourcesets to normal gradle. – Jared Burrows Oct 11 '15 at 21:36
  • @JaredBurrows While I agree with you on 1/, 2/ and 3/, I am not sure how 3/ could solve this problem. What do you mean on 4/ ? – Moumou Oct 11 '15 at 21:50
  • You should not have to specify sourcesets at all. – Jared Burrows Oct 11 '15 at 21:52
  • @JaredBurrows Ah yes, hadn't really paid attention to my project structure yet :/ – Moumou Oct 11 '15 at 22:00
  • 1
    Just dug out an old version of DexGuard 5.5, and the `docs/gradlebuild.html` states `DexGuard supports gradle-plugin 0.12.1, for Gradle version 1.12).` As @dextor mentioned you'll likely have to update DexGuard to use the latest SDK and gradle plugins. – scottyab Oct 12 '15 at 16:26

2 Answers2

7

Your DexGuard plugin looks terribly outdated. The latest version, according to the GuardSquare website, is 7.0.22.

Upgrading is kind of mandatory, since version 7.x brought compatibility with gradle-plugin 1.3.x and build-tools 23.x.

Sebastiano
  • 12,289
  • 6
  • 47
  • 80
  • Yes, I know. I was looking into that but can't find anything about how to upgrade it. Do I need to buy the new version or what ? – Moumou Oct 12 '15 at 08:58
  • It depends on the license you have/had. In my case, license is renewed on a per-year basis, so if yours is expired you will need to renew it. By doing that, you will have access to the newest versions of DexGuard, which provide compatibility with the latest tools/build tools. – Sebastiano Oct 12 '15 at 09:10
  • Okay I'll look into that (couldn't find anything about license on GuardSquare website). Will ask the person who's in charge of that. – Moumou Oct 12 '15 at 09:27
5

Whats your Logcat Throws

Error:Unable to load class 'com.android.builder.SdkParser'

Cause

This problem is caused by android gradle plugin does not match for gradle version.

Courtesy

Actually you are using old version DexGuard5.5.32 .That's why have problem . Use latest version of Dexguard & latest SDK and gradle plugins .

DexGuard 6.0 released

This section takes you through the steps of hardening your application with DexGuard, from making sure the communication is secure, all the way to encrypting strings and classes.

And upgrade your tools.build:gradle version for better approach .

dependencies {
    classpath ':dexguard:'
    classpath 'com.android.tools.build:gradle:1.4.0-beta2'
}

Regards

You can set compileSdkVersion 23 instead of 22 .

Try this way .I hope it will helps you .

Community
  • 1
  • 1
IntelliJ Amiya
  • 74,896
  • 15
  • 165
  • 198