Gradle错误使用fbutton

时间:2018-02-10 15:51:23

标签: android gradle configuration

我的gradle配置有问题。在我的应用程序中我使用FButton,当我使用它时,我的版本gradle有问题所以我将版本3.0.1更改为2.3.3但现在当我重建我的gradle时出现此错误:错误:原因:未指定buildToolsVersion。

build.gradle(Project)

buildscript {

repositories {
    google()
    jcenter()
    mavenCentral()
}
dependencies {
    classpath 'com.android.tools.build:gradle:2.3.3'
    classpath 'com.google.gms:google-services:3.1.0'
}
allprojects {
repositories {
    google()
    jcenter()
}
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

的build.gradle(模块)

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "com.example.dell.eatapp"
        minSdkVersion 21
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:26.1.0'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    androidTestCompile ('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })

    compile 'com.google.firebase:firebase-core:10.2.0'
    compile 'com.google.firebase:firebase-database:10.2.0'
    compile 'info.hoang8f:fbutton:1.0.5'
    compile 'com.rengwuxian.materialedittext:library:2.1.4'
}

apply plugin: 'com.google.gms.google-services'

1 个答案:

答案 0 :(得分:0)

解决方案相当简单,通过降级gradle版本,您更改了build.gradle脚本的需求。

只需向您的模块build.gradle添加此版本所需的buildToolsVersion

android {
    buildToolsVersion = "26.0.2"

    //... other android configs
}

您可以阅读针对3. gra.X版本的android gradle插件所做的更改here

文章中的重要标注:

  

您不再需要为构建工具指定版本(所以,您   现在可以删除android.buildToolsVersion属性)。默认情况下,   该插件自动使用最低要求的构建工具版本   对于您正在使用的Android插件版本。

总而言之,由于您降级到3.0.0以下,现在需要将buildToolsVersion添加回gradle脚本。

祝你好运,快乐的编码!