2014-06-11 50 views
2

我升级了Android Studio来AS 0.6然后导入0.3Android studio构建脚本错误,发现不支持的gradle DSL方法:android()!

我收到错误,如开发项目:

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 
} 

这可能是什么问题?

是否有指导说明如何升级项目?

回答

2

其实它在错误信息中说明。因此,只要

apply plugin: 'com.android.application' 

之间dependencies部分和android部分

-1

“摇篮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.+' 

你会看到一个错误,说“不支持的摇篮DSL方法发现:‘没有()’”显然“没有”不是一个真正的方法。我只是做了。

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

相关问题