2

I am using android studio 1.4 gradle version 2.4 android plugin version 1.3.0

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

Possible causes:

  • The project 'Up_13_7_2015' 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
  • Build.gradle file is

    android {
        compileSdkVersion 19
        buildToolsVersion "19.0.0"
    
        sourceSets {
            main {
                manifest.srcFile 'AndroidManifest.xml'
                java.srcDirs = ['src']
                resources.srcDirs = ['src']
                aidl.srcDirs = ['src']
                renderscript.srcDirs = ['src']
                res.srcDirs = ['res']
                assets.srcDirs = ['assets']
            }
    
            // Move the tests to tests/java, tests/res, etc...
            instrumentTest.setRoot('tests')
    
            // Move the build types to build-types/<type>
            // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
            // This moves them out of them default location under src/<type>/... which would
            // conflict with src/ being used by the main source set.
            // Adding new build types or product flavors should be accompanied
            // by a similar customization.
            debug.setRoot('build-types/debug')
            release.setRoot('build-types/release')
    
    
        }
    }
    dependencies {
        apply plugin: 'announce'
        compile fileTree(dir: 'libs', include: '*.jar')
        compile project(':Downloads:Android-ViewPagerIndicator-master:library')
        classpath 'com.android.tools.build:gradle:1.3.0'
    }
    
    Taslim Oseni
    • 6,086
    • 10
    • 44
    • 69
    android
    • 89
    • 11

    3 Answers3

    8

    Look for the errors in your project-level build.gradle file and fix them.

    In my case the issue appeared when I added new library module to the project. My build.gradle looked like this:

    // Top-level build file where you can add configuration options common to all sub-projects/modules.
    
    buildscript {
        ext.kotlin_version = '1.3.50' '1.3.31'
        repositories {
            google()
            jcenter()
    
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:3.5.0'
            classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
            // NOTE: Do not place your application dependencies here; they belong
            // in the individual module build.gradle files
        }
    }
    
    allprojects {
        repositories {
            google()
            jcenter()
    
        }
    }
    
    task clean(type: Delete) {
        delete rootProject.buildDir
    }
    

    As you can see this line is incorrect:

    ext.kotlin_version = '1.3.50' '1.3.31'
    

    I changed it to

    ext.kotlin_version = '1.3.50' 
    

    and I'm not getting the error anymore.

    Micer
    • 8,731
    • 3
    • 79
    • 73
    0

    The compile statements must be in the app module's build.gradle so if you remove them from this files and add them there, it'll work.

    Moh Mah
    • 2,005
    • 20
    • 29
    • there's a `build.gradle` file in the root of the project and there's a `build.gradle` file in your `app` folder, I meant the latter – Moh Mah Oct 08 '15 at 07:12
    • @android also you should take a look at [this answer](http://stackoverflow.com/a/26851467/772357) – Moh Mah Oct 08 '15 at 07:15
    • i did not have any app folder i exported my project from eclipse....is that a problem... – android Oct 08 '15 at 07:22
    0

    You need

    apply plugin: 'com.android.application'
    

    at the top of you app module build.gradle file, before the android { }.

    laalto
    • 150,114
    • 66
    • 286
    • 303
    • after adding that it is showing Error:(4, 0) Plugin with id 'com.android.application' not found. "openFile:/home/data/AndroidStudioProjects/Up_13_7_2015/build.gradle">Open File – android Oct 09 '15 at 05:10
    • So, what's in your project root level build.gradle then? – laalto Oct 09 '15 at 05:12
    • the above file is in root level build.gradle – android Oct 09 '15 at 05:15
    • The `android` stuff goes to a module (subdirectory) specific build.gradle, not the project-level that usually just configures repositories and so on. – laalto Oct 09 '15 at 05:17
    • i exported my project from eclipse and it is showing only one build.gradle file in my project....is that a problem.. – android Oct 09 '15 at 05:22