IllegalStateException:buildToolsVersion is not specified
Asked Answered
S

7

1

My project is comprised of two modules, one is the application module and the other is a library module. My build processes works fine until I added two gradle plugins :

This is the root 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 a library module build.gradle:

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 there are something wrong with the build files, but I got a 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 issue happen and how to solve this ?

I have searched some answer, but not work for me, are there something wrong in the two plugins which I import ?

Sianna answered 21/7, 2016 at 6:40 Comment(0)
S
2

OK, after a lot searchings about this issue, I finally worked it out.

I'm 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 a lot of differences, and here we can see more details.

Sianna answered 21/7, 2016 at 8:8 Comment(0)
P
1

I had that error until I shorten the version code length from "2017041201" to 8 characters number:

android-versionCode="20170412"
Pavia answered 15/4, 2017 at 9:6 Comment(0)
M
1

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

For some reason I got this error from Cordova/Ionic when installing a plugin.

It was fixed when I typed the command

ionic plugin add foo

instead of (leading space)

 ionic plugin add foo
Marcelo answered 3/5, 2017 at 7:52 Comment(0)
A
1

i have a same issue, and the problem was that have dot in android-versionCode,
like: android-versionCode="10001.1"

Afforest answered 26/4, 2018 at 10:12 Comment(0)
U
0

You are missing mavencentral() in repository dependency. Maybe that is causing the issue

repositories {

    mavenCentral()
}
Unholy answered 21/7, 2016 at 6:54 Comment(0)
P
0

I get this error coz of the ANDROID_HOME getting set to /usr/local/Caskroom/android-platform-tools/latest.

I do not know why it's getting set to the above mentioned value. But after correcting this and setting it to /Users/<user_name>/Library/Android/sdk/, the error goes away.

Petrolatum answered 14/6, 2017 at 18:7 Comment(0)
I
0

This worked for me

Remove android / Add android:
cordova platform rm android
cordova platform add android
Inhume answered 29/10, 2019 at 9:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.