I’ve been trying to import a project to Android Studio and this is where I am stuck, there is a similar question on Stack Overflow but it did not provide a solution to my particular error.
This is my error log:
The Gradle sync messages are:
Error:(24, 0) Gradle DSL method not found: ‘android()’ Possible causes:
The project ‘PoojaPeople’ may be using a version of Gradle that does not contain the method. Gradle settings The build file may be missing a Gradle plugin. Apply Gradle plugin
I’m not too sure where exactly this method android() is located. If it is the one located in Application’s build.gradle file, I still don’t exactly know where to go from here. Any help is appreciated.
My build.gradle is

3 Answers 3
You are using the wrong build.gradle file.
In your top-level file you can’t define an android block.
Just move this part inside the module/build.gradle file.
guys. I had the same problem before when I’m trying import a .aar package into my project, and unfortunately before make the .aar package as a module-dependence of my project, I had two modules (one about ROS-ANDROID-CV-BRIDGE, one is OPENCV-FOR-ANDROID) already. So, I got this error as you guys meet:
So, it’s the painful gradle-structure caused this problem when you have several modules in your project, and worse, they’re imported in different way or have different types (.jar/.aar packages or just a project of Java library). And it’s really a headache matter to make the configuration like compile-version, library dependencies etc. in each subproject compatible with the main-project.
I solved my problem just follow this steps:
① Copy .aar package in app/libs.
② Add this in app/build.gradle file:
③ Add this in your add build.gradle file of the module which you want to apply the .aar dependence (in my situation, just add this in my app/build.gradle file):
So, if it’s possible, just try export your module-dependence as a .aar package, and then follow this way import it to your main-project. Anyway, I hope this can be a good suggestion and would solve your problem if you have the same situation with me.
I am trying to do a grade sync on my android studio project and I keep getting this error in the title. My build.gradle file is
My error message is
I have looked online and tried multiple solutions but nothing seems to work. What does this even mean? Any help would be appreciated.
6 Answers 6
You are using the wrong build.gradle file.
In your top-level file, you can’t define an android block.
Just move this part inside the module/build.Gradle file.

currently you are editing top level gradle file but you have to edit App level

Each module you add in your Android Studio Project has its own build.gradle file. Any dependencies that you want to add is added in associated module build.gradle file. So in your case you have to add your dependencies in your app’s build.gradle file.
Here is an image showing where you should add that.
Error:(22, 0) Gradle DSL method not found: ‘android()’
Possible causes:
- The project ‘Test2’ may be using a version of Gradle that does not contain the method.
Open Gradle wrapper file - The build file may be missing a Gradle plugin.
Apply Gradle plugin
plugin gradle установлен
- Вопрос задан более трёх лет назад
- 632 просмотра
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript <
repositories <
jcenter()
>
/* dependencies <
classpath ‘com.android.tools.build:gradle:2.0.0’
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
>*/
>
allprojects <
repositories <
jcenter()
>
>
task clean(type: Delete) <
delete rootProject.buildDir
>
android <
// compileSdkVersion 18
// buildToolsVersion ‘19.1.0’
signingConfigs <
config <
>
>
compileSdkVersion 18
buildToolsVersion ‘19.1.0’
defaultConfig <
minSdkVersion 18
targetSdkVersion 18
>
productFlavors <
>
>
dependencies <
>