Search code examples
android-studioandroid-gradle-pluginbuild.gradlegoogle-glassandroid-studio-2.1

errors with gradle in android studio


I am trying to build the project and run it in my google glass but when ever i am trying to build it is showing that

Error:(20, 0) Gradle DSL method not found: 'runProguard()' Possible causes:

  • The project 'gdk-stopwatch-sample' may be using a version of Gradle that does not contain the method. Gradle settings
  • The build file may be missing a Gradle plugin. Apply Gradle plugin
  • but i have installed the latest gradle plugin i.e 2.13, changed the classpath in build.gradle to 'com.android.tools.build:gradle:2.1.3', gradle-wrapper properties to (distributionUrl=https://services.gradle.org/distributions/gradle-2.13-all.zip), deleted the .gradle file in Users but it keeps on appearing again and again, and also in settings I marked as offline work, service directory path keeps on appearing though

    Updated Manifest

    <?xml version="1.0" encoding="utf-8"?>
    

    <uses-sdk android:minSdkVersion="19" android:targetSdkVersion="19" />
    
    <application>
        <uses-library android:name="android.test.runner" />
    </application>
    
    <instrumentation android:name="android.test.InstrumentationTestRunner"
                     android:targetPackage="com.google.android.glass.sample.stopwatch"
                     android:handleProfiling="false"
                     android:functionalTest="false"
                     android:label="Tests for com.google.android.glass.sample.stopwatch"/>
    


    Solution

  • It happens because the gradle plugin for Android 2.1.3 doesn't exist.
    Don't confuse the gradle version with the gradle plugin.

    Use

    buildscript {
    
        repositories {
            jcenter()
        }
    
        dependencies {
            classpath 'com.android.tools.build:gradle:2.1.0'
        }
    }
    

    About the runProguard change your script with:

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