Android Studio中gradle的错误 [英] errors with gradle in android studio

查看:149
本文介绍了Android Studio中gradle的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试构建该项目并在我的Google Glass中运行它,但是每当我试图构建该项目时,它就会显示

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

错误:(20,0 )找不到Gradle DSL方法:'runProguard()'
可能的原因:

  • 项目'gdk-stopwatch-sample'可能正在使用不包含该方法的Gradle版本。
    Gradle设置
  • 构建文件可能缺少Gradle插件。
    应用Gradle插件

  • ,但是我安装了最新的gradle插件,即2.13,将build.gradle中的类路径更改为'com.android.tools.build:gradle:2.1.3', gradle-wrapper属性为(distributionUrl = https://services.gradle.org/distributions /gradle-2.13-all.zip ),删除了用户中的.gradle文件,但该文件不断出现,并且在我标记为脱机工作的设置中,服务目录路径仍然出现

    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

    清单更新

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

    推荐答案

    发生这种情况是因为Android 2.1.3的gradle插件不存在

    不要将gradle版本与gradle插件混淆。

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

    使用

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

    关于 runProguard 使用以下命令更改脚本:

    About the runProguard change your script with:

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

    这篇关于Android Studio中gradle的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆