Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error:(26, 0) Gradle DSL method not found: 'runProguard()'

People also ask

What is DSL in Gradle?

Simply, it stands for 'Domain Specific Language'. IMO, in gradle context, DSL gives you a gradle specific way to form your build scripts. More precisely, it's a plugin-based build system that defines a way of setting up your build script using (mainly) building blocks defined in various plugins.

How do I resolve Gradle build problem?

For this, you have to connect your PC to the internet and you have to open your Android studio. After opening your project click on the Sync Project with Gradle files option. This will automatically download the new Gradle files and will fix the issue which is caused by the Gradle files.

What is Android Gradle DSL?

The Android Gradle Plugin (AGP) is the supported build system for Android applications and includes support for compiling many different types of sources and linking them together into an application that you can run on a physical Android device or an emulator.


Instead of using runProguard in your gradle file, try using minifyEnabled. This should fix the issue. runProguard is deprecated and soon be stop working.

EDIT

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


Change in the app build.gradle file may help:

old:

buildTypes {
    release {

        runProguard false // this line has to be changed

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

new:

buildTypes {
    release {

        minifyEnabled false // new version

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

As far as I know runProguard was replaced with minifyEnabled. I am still not sure how to define the config for proguard but a Google search should help you to find out.

Edit:

For the outFile read here: https://groups.google.com/forum/#!topic/adt-dev/4_-5NvxuFB0 how they do it.

In short: they used a more complex version:

applicationVariants.all { variant ->

    variant.outputs.each { output ->

        def apk = output.outputFile;
        def newName;

        // newName = apk.name.replace(".apk", "-v" + defaultConfig.versionName + "-" + variant.buildType.name.toUpperCase() + ".apk");
        if (variant.buildType.name == "release") {
            newName = apk.name.replace(".apk", "-v" + defaultConfig.versionName + "-release.apk");
        } else {
            newName = apk.name.replace(".apk", "-v" + defaultConfig.versionName + "-beta.apk");
        }

        output.outputFile = new File(apk.parentFile, newName);

        if (output.zipAlign) {
            output.outputFile = new File(apk.parentFile, newName.replace("-unaligned", ""));
        }

        logger.info('INFO: Set outputFile to ' + output.outputFile + " for [" + output.name + "]");
    }
}

If you are using version 0.14.0 or higher of the gradle plugin, you should replace "runProguard" with "minifyEnabled" in your build.gradle files.

Just add this.

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

minifyEnabled false Means Build Type names cannot be main or androidTest (this is enforced by the plugin), and that they have to be unique to each other.

The new version of the Android Gradle plugin, can automatically remove unused resources. The big win here is that it removes unused resources not just from your own code, but more importantly from libraries you are using (e.g. where there are resources included to support features that you are not actually using from your app).


As of Gradle 0.14.4, these errors are reported as compile-time errors.

So you have to replace runProguard false/true with minifyEnabled false/true

The changes are listed on Android Developers Blog.


Migrating Gradle Projects to version 1.0.0 needs some easy renaming work, everything is described here: http://tools.android.com/tech-docs/new-build-system/migrating-to-1-0-0

For proguard you can simply rename 'runProguard' => 'minifyEnabled', for the others see below:

Renamed Properties in BuildTypes:    
runProguard => minifyEnabled
zipAlign => zipAlignEnabled
jniDebugBuild => jniDebuggable
renderscriptDebug => renderscriptDebuggable

Renamed Properties in ProductFlavors:    
flavorGroups => flavorDimensions
packageName => applicationId
testPackageName => testApplicationId
renderscriptSupportMode => renderscriptSupportModeEnabled
ProductFlavor.renderscriptNdkMode => renderscriptNdkModeEnabled
Other Name changes

InstrumentTest was renamed to androidTest.