getDefaultProguardFile can not be resolved

Question!

I'm trying to activate ProGuard in my project, however getDefaultProguardFile method says it can not be resolved.

Here's my build.gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1"
    defaultConfig {
        applicationId '***'
        minSdkVersion 11
        targetSdkVersion 22
    }
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
    productFlavors {
    }
}

dependencies {
    compile 'com.android.support:appcompat-v7:22.0.0'
    compile 'com.android.support:support-v4:22.0.0'
    compile 'com.google.android.gms:play-services:7.0.0'
    compile project(path: ':backend', configuration: 'android-endpoints')
}
By : RedEagle


Answers

Try checking the file is in the correct folder and the applicationId in defaultConfig must be your package name.

defaultConfig {
    applicationId 'com.package.name'
    minSdkVersion 11
    targetSdkVersion 22
}


Try changing

proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'

to (txt -> pro)

proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

Hopefully that will help!



This video can help you solving your question :)
By: admin