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

馋奶兔 提交于 2019-11-29 00:18:54

问题


What should i do to fix this issue? I am getting this error when i ever i run my project in android studio0.9.1

android {compileSdkVersion 17
buildToolsVersion "19.1.0"

defaultConfig {
    applicationId "com.example.nearby"
    minSdkVersion 11
    targetSdkVersion 19
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
    }
}}dependencies {
compile 'com.android.support:support-v4:19.0.0'
compile 'com.google.android.gms:play-services:+'
compile 'com.android.support:appcompat-v7:19.0.0'
compile files('libs/google-play-services.jar')}

回答1:


I just ran into this same error. Make sure you don't have an android block in the top-level build.gradle for the project, only in the module's build.gradle file.

This happened to me when AndroidStudio tried to import and existing, buildable Eclipse/ADT project–I had to cut and paste the android block from one gradle file to the other. I don't know if this has been fixed in more recent versions of AndroidStudio.




回答2:


I ran into the same problem. My fix was adding "apply plugin: 'android'" before android block... Hope it helps anyone.




回答3:


Inspired by Ionoclast Brigham's answer I've checked both gradle files. I had android() in both of them... but instead of moving android() from the root one to module one I've just added

apply plugin: 'android'

to root one and build works fine.




回答4:


in my case i had to delete these lines from the top-level build.gradle file as it's a bug in the android studio which inserts this

android {
    compileSdkVersion 23
    buildToolsVersion '23.0.1'
}



回答5:


Solution is found here under runProguard section. In short, it says;

To update your project, edit your build.gradle file as follows:

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


来源:https://stackoverflow.com/questions/26759755/error1-0-gradle-dsl-method-not-found-android

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!