Error:Cause: buildToolsVersion is not specified
AndroidAndroid StudioAndroid Problem Overview
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.
Android Solutions
Solution 1 - Android
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.
Solution 2 - Android
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'
}
Solution 3 - Android
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!!!
Solution 4 - Android
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'
Solution 5 - Android
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.
Solution 6 - Android
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".
Solution 7 - Android
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.
Solution 8 - Android
Android Project > setting.gradle
include ':app' , ':xxx'
I imported one of module and this coused this error. I remove it is fixed.
include ':app'
Solution 9 - Android
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
Solution 10 - Android
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
Solution 11 - Android
I had same error, I using cordova and resolve by removing the space character
> id="com.xx.yy " => to id="com.xx.yy"
Solution 12 - Android
Try to invalidate caches / restart , it fixed this like this after updated File-> Invalidate caches/restart