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

自古美人都是妖i 提交于 2019-11-30 02:39:57

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.

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

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.

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'
}

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