Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

build.gradle

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')}
like image 361
Youri Avatar asked Nov 05 '14 14:11

Youri


People also ask

What is DSL in Gradle?

Simply, it stands for 'Domain Specific Language'. IMO, in gradle context, DSL gives you a gradle specific way to form your build scripts. More precisely, it's a plugin-based build system that defines a way of setting up your build script using (mainly) building blocks defined in various plugins.

What is Android Gradle DSL?

The Android Gradle Plugin (AGP) is the supported build system for Android applications and includes support for compiling many different types of sources and linking them together into an application that you can run on a physical Android device or an emulator.

How do I fix Gradle issues?

For this, you have to connect your PC to the internet and you have to open your Android studio. After opening your project click on the Sync Project with Gradle files option. This will automatically download the new Gradle files and will fix the issue which is caused by the Gradle files.

Why is Gradle DSL method not found in Android?

So if you have updated your gradle configuration to use the new gradle plugin, and the new android plugin, but didn't change the module's build.gradle syntax, you could get "Gradle DSL method not found: 'android ()'" error.

Why can't I import an eclipse NDK project into Android Studio?

I got this same error when I was trying to import an Eclipse NDK project into Android Studio. It turns out, for NDK support in Android Studio, you need to use a new gradle and android plugin (and gradle version 2. 5+ for that matter). This plugin, requires changes in the module's build. gradle file. android {. }" object should be inside" model {.

Is it safe to install Gradle after installing Android Studio?

this method works fine if your Gradle installation is healthy. If you just installed Android studio and did not modify it, the Gradle installation should be fine.

What happened to compile () configuration in Android Gradle?

3 implementation()has replaced compile()configuration, which will be DEPRECATED by the end of 2018. In order to fix your errors and use it, you must update to Android Gradle Plugin 3.0.0(or higher). As a result of this update, you also need to update Gradle to Gradle 4.1(or higher).


3 Answers

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.

like image 151
Ionoclast Brigham Avatar answered Oct 19 '22 21:10

Ionoclast Brigham


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

like image 23
fmmarques Avatar answered Oct 19 '22 19:10

fmmarques


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.

like image 5
sdf3qrxewqrxeqwxfew3123 Avatar answered Oct 19 '22 20:10

sdf3qrxewqrxeqwxfew3123