未指定IllegalStateException:buildToolsVersion [英] IllegalStateException:buildToolsVersion is not specified

查看:452
本文介绍了未指定IllegalStateException:buildToolsVersion的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的项目由两个模块组成,一个是应用程序模块,另一个是库模块.在添加两个gradle插件之前,我的构建过程可以正常工作:

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 :

这是根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
}

这是一个库模块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'
}

我认为构建文件没有问题,但是运行gradle clean时出现错误:

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 ?

推荐答案

好的,经过大量搜索,我终于解决了.

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

我正在使用Gradle 2.14,所以我需要更改

I'm using Gradle 2.14, so I need to change

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

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

有很多差异,并且在这里,我们可以看到更多详细信息

There are a lot of differences, and here we can see more details.

这篇关于未指定IllegalStateException:buildToolsVersion的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆