【问题标题】:Android studio build script error,unsupported gradle DSL method found : android()!Android Studio 构建脚本错误,发现不支持的 gradle DSL 方法:android()!
【发布时间】:2014-06-11 12:58:13
【问题描述】:

我将Android Studio升级到AS 0.6,然后导入AS 0.3开发的项目

我收到如下错误:

Build script error,unsupported Gradle DSL method found : android()'!,

Possible causes could be:  

 - you are using Gradle version where the method is absent 
    ("open_gradle_settings">Fix Gradle settings</a>)

 - you didn't apply Gradle plugin which provides the method 
    (<a href="apply_gradle_plugin">Apply Gradle plugin</a>)

or there is a mistake in a build script (<a href="goto_source">Goto source</a>)

我将 build.gradle 中的依赖路径更改为:

dependencies {
    classpath 'com.android.tools.build:gradle:0.11.+'
}

android {
    compileSdkVersion 19
    buildToolsVersion "19.1.0"

    defaultConfig {
        minSdkVersion 14
        targetSdkVersion 14
}

可能有什么问题?

有没有说明如何升级项目的指南?

【问题讨论】:

    标签: android-studio


    【解决方案1】:

    实际上它在错误消息中说明。所以只需添加

    apply plugin: 'com.android.application'
    

    dependencies 部分和android 部分之间

    【讨论】:

      【解决方案2】:

      将“Gradle DSL 方法”视为一种 Java 方法。所以在 Gradle 中,方法可以用 {} 或“.”来区分。所以

      dependencies {
          compile fileTree(dir: 'libs', include: ['*.jar'])
      }
      

      一样
      dependencies.compile fileTree(dir: 'libs', include: ['*.jar'])
      

      “依赖项”和“编译”都是方法。

      因此,您在 build.gradle 文件的某处包含了您的程序不支持的方法。例如,使您的依赖项如下:

      dependencies {
          nothing 'this.does.nothing.build:gradle:0.7.+'
      }
      

      这和写的一样:

      dependencies.nothing 'this.does.nothing.build:gradle:0.7.+'
      

      您会看到一条错误消息“找到不支持的 Gradle DSL 方法:‘nothing()’!” 显然“无”不是真正的方法。我只是编的。

      所以你的“android”方法之一是错误的。

      【讨论】:

        猜你喜欢
        • 2014-06-18
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-09-21
        • 1970-01-01
        • 1970-01-01
        • 2014-09-03
        • 1970-01-01
        相关资源
        最近更新 更多