developer
developer

Reputation: 613

Error:Cause: buildToolsVersion is not specified

I create a simple project and then I right-click on the project and then I use the make mudole app option. Now I have two build.gradle folders: 1- build.gradle:project My Application. 2- build.gradle: Mudole app. the first build.gradle is as follows:

// Top-level build file where you can add configuration options common to all sub-projects/modules.
apply plugin: 'com.android.library'
buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.3.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

And the second Build.gradle folder is as follows:

 apply plugin: 'com.android.application'
android {
    compileSdkVersion 23
    buildToolsVersion "23.0.0"

    defaultConfig {
        applicationId "com.exam.exam.myapplication"
        minSdkVersion 7
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
}

And now I click on the run option to create aar file from this project But I get the following error:

Error:Cause: buildToolsVersion is not specified.

Upvotes: 61

Views: 101870

Answers (12)

Mitrakov Artem
Mitrakov Artem

Reputation: 1513

Might be helpful for someone: in my case long time ago I had added keystore properties in build.gradle file for Android:

def keystorePropertiesFile = rootProject.file("keystore.properties")
def keystoreProperties = new Properties()
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))

and after some period of time I pulled repo and forgot to add this file ("keystore.properties").

Gradle for some reason (!) gave me the same error (buildToolsVersion was defined a bit below in build.gradle file). The workaround was just to add missing "keystore.properties" file.

Upvotes: 1

Ferhat KOÇER
Ferhat KOÇER

Reputation: 4065

I had same error, I using cordova and resolve by removing the space character

id="com.xx.yy " => to id="com.xx.yy"

Upvotes: 0

Sagar H
Sagar H

Reputation: 5541

Add buildToolsVersion to your build.gradle file this will solve your problem.

buildToolsVersion "27.0.1"

Gradle file code

 android{
          compileSdkVersion 27
          buildToolsVersion "27.0.1"
          useLibrary 'org.apache.http.legacy'
        }

Upvotes: 13

DesignIsLife
DesignIsLife

Reputation: 530

Add buildToolsVersion property to your local build.gradle file.

android {
    compileSdkVersion 27
    buildToolsVersion "26.0.1"

    defaultConfig {
        targetSdkVersion 27
    }
}

As per your requirements!! Then Try to build -> you will get build failure and this message :

Failed to find Build Tools revision 26.0.1

Install Build Tools 26.0.1 and sync project

Then Click to Install build tools and your project is configured and you are good to go!!!

Upvotes: 8

AflamZone
AflamZone

Reputation: 91

for me it was an additional classpath line for example :

classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.0'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'

so i was deleting the first

classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.0'

and the issue solved

Upvotes: 0

user1662871
user1662871

Reputation: 19

Check if android studio version in build.gradle is same as the one you are running.

buildscript {

   repositories {
       google()
       jcenter()
   }
 dependencies {
    classpath 'com.android.tools.build:gradle:3.0.0'


    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
  }
}   

In my case, I opened/imported the project created on android studio 2.3.3 in android studio 3 and i was able to get rid of this issue after updating the build.gradle with 3.0.0

Upvotes: 0

Srikanth Nutigattu
Srikanth Nutigattu

Reputation: 41

The issue for me was that andorid-versionCode can only be integer value. in build.xml:

eg:android-versionCode="1"

It cannot be "1.1" etc... The error code is not helpful at all.

Upvotes: 4

Akshay
Akshay

Reputation: 1020

I had the same issue. What I was doing wrong was the placing of apply plugin statement in the root gradle of the project. When I placed it in the app gradle then the issue got resolved.

What I would suggest is to check if you are placing some statement in the root gradle that you should be placing in the app gradle.

Upvotes: 82

Huseyin
Huseyin

Reputation: 567

Android Project > setting.gradle

include ':app' , ':xxx'

I imported one of module and this coused this error. I remove it is fixed.

include ':app'

Upvotes: 0

JCricket
JCricket

Reputation: 1329

Not really sure what the underlying problem was, but I found the solution in a concurrent problem that was occurring: https://stackoverflow.com/a/32490472/1544046

Essentially, I had to change my gradle target to use the wrapper and not a defined path. I've had it set to the Gradle Wrapper in the past, but it seems to revert from time to time without notice. Once I switched back and recompiled it worked fine.

In the project's settings: Build, Execution, Deployment->Build Tools->Gradle and select "Use default gradle wrapper".

Upvotes: 1

RickPat
RickPat

Reputation: 487

in file... build.gradle(Project: XXX):

repositories{
     //put pluging repository here
     //e.g.:
     mavenCentral()
}
dependencies{
     //classpath to plugin here
     classpath 'com.XXXX.xXXxxXX.XXXX' 
}

in file.... build.gradle(Module: app)

//add on top:
apply plugin: 'com.YOUR.PLUGIN.XXX'

Upvotes: 7

Kirtan
Kirtan

Reputation: 1812

Try to invalidate caches / restart , it fixed this like this after updated File-> Invalidate caches/restart

Upvotes: -5

Related Questions