1

I am getting an error whenever I try to add "runProguard", here is my code:

 release {
            minifyEnabled false
            runProguard true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }

and here is the error:

Could not find method runProguard() for arguments [true] on BuildType_Decorated{name=release, debuggable=false, testCoverageEnabled=false, jniDebuggable=false, pseudoLocalesEnabled=false, renderscriptDebuggable=false, renderscriptOptimLevel=3, minifyEnabled=false, zipAlignEnabled=true, signingConfig=null, embedMicroApp=true, mBuildConfigFields={}, mResValues={}, mProguardFiles=[], mConsumerProguardFiles=[], mManifestPlaceholders={}} of type com.android.build.gradle.internal.dsl.BuildType.

Suraj Vaishnav
  • 7,777
  • 4
  • 43
  • 46
Tomas Mota
  • 672
  • 5
  • 27

2 Answers2

1

Using minifyEnabled and making it true will enable the Proguard. I'm guessing that runProguard is depreciated-old that's why you get the error.

So add:

minifyEnabled true

Note that to use minifyEnabled, gradle should be updated to version 2.2 or above.

ʍѳђઽ૯ท
  • 16,646
  • 7
  • 53
  • 108
  • I added the "minifyEnabled true" to my code, although it still shows the same error, could you help me updating my gradle please? – Tomas Mota Sep 30 '18 at 18:27
  • Remove `runProguard` and then use : `classpath 'com.android.tools.build:gradle:3.2.0'` for updating the gradle and only this `minifyEnabled true` for proguard and then it should work. – ʍѳђઽ૯ท Sep 30 '18 at 18:28
  • Should I insert the: classpath 'com.android.tools.build:gradle:3.2.0' on the line that I removed the runProguard? – Tomas Mota Sep 30 '18 at 18:33
  • "Could not find method classpath() for arguments [com.android.tools.build:gradle:3.2.0] on BuildType_Decorated{name=release, debuggable=false, testCoverageEnabled=false, jniDebuggable=false, pseudoLocalesEnabled=false, renderscriptDebuggable=false, renderscriptOptimLevel=3, minifyEnabled=true, zipAlignEnabled=true, signingConfig=null, embedMicroApp=true, mBuildConfigFields={}, mResValues={}, mProguardFiles=[], mConsumerProguardFiles=[], mManifestPlaceholders={}} of type com.android.build.gradle.internal.dsl.BuildType." – Tomas Mota Sep 30 '18 at 18:34
  • Okay, did it, now I get this error "Plugin with id 'com.android.tools.build:gradle:3.2.0' not found." – Tomas Mota Sep 30 '18 at 18:36
  • Yes I am, 3.2 I guess, how do I give you the link? – Tomas Mota Sep 30 '18 at 18:41
  • Oh, I'm sorry, I just got to the right file, and there was the line of code already there, what should I do? – Tomas Mota Sep 30 '18 at 18:48
  • Replace it with: `classpath 'com.android.tools.build:gradle:3.2.0'` (new version) – ʍѳђઽ૯ท Sep 30 '18 at 18:49
-1

I have encounter a same problem some days ago and i solve this by making my "minifyEnabled false" this may help you try it

 buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
Kunal Nikam
  • 79
  • 1
  • 11