Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle sync fails with Dexguard plugin (Android Studio)

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 ??

like image 774
Moumou Avatar asked Dec 24 '22 13:12

Moumou


2 Answers

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.

like image 121
Sebastiano Avatar answered Dec 27 '22 02:12

Sebastiano


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 .

like image 29
IntelliJ Amiya Avatar answered Dec 27 '22 01:12

IntelliJ Amiya