0

I have tried a lot to find solution to this. I am trying to build my android app from command line using gradle, I am getting the following error

A problem occurred evaluating root project 'android-build'.
> Could not find method android() for arguments [build_bumi6pcyg9xxwmbnm52kyqutw$_run_closure1@6ba7383d] on root project 'android-build'.

Can someone pls point out what I is wrong ?

Following is my build.gradle

buildscript {
    repositories {
        maven  {
            url "http://repo1.maven.org/maven2"
        }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.1.3'
    }
}

android {
    compileSdkVersion 23
    buildToolsVersion "21.1.2"

    def versionPropsFile = file('version.properties')

    if (versionPropsFile.canRead()) {
        def Properties versionProps = new Properties()

        versionProps.load(new FileInputStream(versionPropsFile))

        def code = versionProps['VERSION_CODE'].toInteger() + 1

        versionProps['VERSION_CODE']=code.toString()
        versionProps.store(versionPropsFile.newWriter(), null)

            defaultConfig {
            versionCode code
            versionName "1.1"
            minSdkVersion 14
            targetSdkVersion 18
        }
    }
    else {
        throw new GradleException("Could not read version.properties!")
    }
}
TheWaterProgrammer
  • 7,055
  • 12
  • 70
  • 159
  • Hi, try below links, maybe it will work. http://stackoverflow.com/questions/37250493/could-not-find-method-android-for-arguments http://stackoverflow.com/questions/26243480/could-not-find-method-android-for-arguments-when-building-android-project-from – Jay Oct 11 '16 at 21:34

1 Answers1

0

You need to add this configuration at the first line of your module build.gradle file:

apply plugin: 'com.android.application'

As specified in android's developer guide:

The first line in the build configuration applies the Android plugin for Gradle to this build and makes the android {} block available to specify Android-specific build options.

Aram Tchekrekjian
  • 925
  • 11
  • 26