IllegalStateException: buildToolsVersion not specified

My project consists of two modules: one is an application module and the other is a library module. My build processes work fine until I added two gradle :

This is the root of build.gradle :

 buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:2.1.2' classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3' classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.4' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } allprojects { repositories { jcenter() } } task clean(type: Delete) { delete rootProject.buildDir } 

This is the build.gradle library module:

 apply plugin: 'com.android.library' apply plugin: 'com.github.dcendents.android-maven' apply plugin: 'com.jfrog.bintray' android { compileSdkVersion 24 buildToolsVersion "24.0.0" resourcePrefix "looping_banner_res_" defaultConfig { minSdkVersion 16 targetSdkVersion 24 versionCode 1 versionName "1.0" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { compile 'com.android.support:support-v4:24.1.0' } 

I don't think that something is wrong with the build files, but I got an error when I run gradle clean :

 Failed to notify ProjectEvaluationListener.afterEvaluate(), but primary configuration failure takes precedence. java.lang.IllegalStateException: buildToolsVersion is not specified. at com.google.common.base.Preconditions.checkState(Preconditions.java:176) at com.android.build.gradle.BasePlugin.createAndroidTasks(BasePlugin.java:606) at com.android.build.gradle.BasePlugin$10$1.call(BasePlugin.java:572) at com.android.build.gradle.BasePlugin$10$1.call(BasePlugin.java:569) at com.android.builder.profile.ThreadRecorder$1.record(ThreadRecorder.java:55) at com.android.builder.profile.ThreadRecorder$1.record(ThreadRecorder.java:47) at com.android.build.gradle.BasePlugin$10.execute(BasePlugin.java:568) at com.android.build.gradle.BasePlugin$10.execute(BasePlugin.java:565) * Where: Build file '/home/lic/code/private/github/looping-banner/banner/build.gradle' line: 3 

Why did this problem arise and how to solve it?

I was looking for some answer, but it didn’t work for me, is there something wrong with the two plugins that I import?

+1
source share
5 answers

Well, after a long search on this issue, I finally decided.

I am using Gradle 2.14, so I need to change

 classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3' 

to

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

There are many differences, and here we can see more detailed information.

+2
source

I had this error until I reduced the length of the version code from "2017041201" to 8 characters:

 android-versionCode="20170412" 
+1
source

This question is old, but I found it because I had this problem -

For some reason, I received this error from Cordova / Ionic when installing the plugin.

It was fixed when I typed a command.

 ionic plugin add foo 

instead (leading space)

  ionic plugin add foo 
+1
source

You are missing mavencentral () depending on the repository. Perhaps this is causing the problem.

 repositories { mavenCentral() } 
0
source

I get this coz error from ANDROID_HOME, which is installed in /usr/local/Caskroom/android-platform-tools/latest .

I do not know why it gets the value set above. But by fixing this and setting it to /Users/<user_name>/Library/Android/sdk/ , the error will disappear.

0
source

All Articles