2014-06-11 52 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」方法是錯誤的。

相關問題