user6617365
user6617365

Reputation:

IllegalStateException:buildToolsVersion is not specified

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 ?

Upvotes: 1

Views: 13633

Answers (7)

Stefan Morcodeanu
Stefan Morcodeanu

Reputation: 2158

This worked for me

Remove android / Add android:
cordova platform rm android
cordova platform add android

Upvotes: 0

izik f
izik f

Reputation: 2467

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

Upvotes: 1

Mav55
Mav55

Reputation: 4280

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.

Upvotes: 0

Simon Visser
Simon Visser

Reputation: 364

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

Upvotes: 1

Dalibor
Dalibor

Reputation: 1572

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

android-versionCode="20170412"

Upvotes: 1

user6617365
user6617365

Reputation:

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.

Upvotes: 2

Abhra
Abhra

Reputation: 61

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

repositories {

    mavenCentral()
}

Upvotes: 0

Related Questions