2015-06-29 83 views
3

我只是升級了android studio和以前編譯的項目現在顯示錯誤!錯誤(19,0)Gradle的DSL方法沒有找到:android()

Error(19,0) Gradle DSL method not found: android()

,這裏是構建腳本和app.build.gradle

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

    // NOTE: Do not place your application dependencies here; they belong 
    // in the individual module build.gradle files 
} 
    } 
    allprojects { 
     repositories { 
    jcenter() 
} 
} 

    android { 
    defaultConfig { 
    minSdkVersion 8 
    targetSdkVersion 22 
} 
productFlavors { 
} 
    } 

dependencies { 
} 

而這裏的build.gradle

apply plugin: 'com.android.application' 

    android { 
compileSdkVersion 21 
buildToolsVersion "21.1.2" 

defaultConfig { 
    applicationId "com.aqsa.personal.newpro" 
    minSdkVersion 8 
    targetSdkVersion 22 
    versionCode 1 
    versionName "1.0" 
} 
buildTypes { 
    release { 

     minifyEnabled false 
     proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
    } 
} 
} 

    dependencies { 
    compile fileTree(dir: 'libs', include: ['*.jar']) 
    compile 'com.android.support:appcompat-v7:21.0.3' 
} 
+0

刪除應用程序的'allprojects'部分後的所有內容build.gradle – nikis

回答

7

Here is the build script and app.build.gradle

allprojects結束後刪除所有組件出頂級build.gradle文件,留給你:

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

    // NOTE: Do not place your application dependencies here; they belong 
    // in the individual module build.gradle files 
} 
    } 
    allprojects { 
     repositories { 
    jcenter() 
} 
} 

android閉合,特別是,需要將正在使用該搖籃之一爲Android插件(例如,com.android.application)一個模塊中。

+0

感謝它工作:) – hyeri

0

從第一碼

android { 
    defaultConfig { 
     minSdkVersion 8 
     targetSdkVersion 22 
    } 
    productFlavors { 
    } 
} 

除去此參見this

0

問題:

Error:(19, 0) Gradle DSL method not found: 'android()'

解決方案:

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

後allprojects代碼刪除,並建立project.this解決方案爲我工作。

相關問題