【问题标题】:Error:Cause: buildToolsVersion is not specified in build.grade (Project:xxx)错误:原因:build.gradle 中未指定 buildToolsVersion(项目:xxx)
【发布时间】:2016-05-03 23:19:06
【问题描述】:

现在我正在尝试将 Fabric 与 Crashlytics (https://docs.fabric.io/android/fabric/integration.html) 集成到现有的 android 应用程序中。

按照 Fabric 提供的集成说明,我将 apply plugin: 'com.android.application' 添加到“build.grade (Project.NumenuApp)”文件的根目录中。我单击以同步 Gradle,但它失败了,我收到此错误 Error:Cause: buildToolsVersion is not specified. Android studio 声明我的插件应该在模块而不是项目级别声明。

我已经在“build.grade (Module:app)”文件中设置了 buildTools。我的问题是为什么会发生这种情况,我该怎么做才能补救?我在下面发布了我的代码。提前致谢。 - 阿德里安

build.grade(项目:NumenuApp)

// Top-level build file where you can add configuration options common to all     sub-projects/modules.

buildscript {
    repositories {
        jcenter()
        maven { url 'https://maven.fabric.io/public' }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.5.0'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
        classpath 'io.fabric.tools:gradle:1.+'
    }
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

allprojects {
    repositories {
        jcenter()
        maven { url 'https://maven.fabric.io/public' }
    }
}

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

build.grade (Module:app)

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

defaultConfig {
    applicationId "com.numenu.numenuapp"
    minSdkVersion 21
    targetSdkVersion 23
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.android.support:design:23.1.1'
    compile 'com.android.support:support-v4:23.1.1'
    compile 'com.android.support:recyclerview-v7:23.1.1'
}

【问题讨论】:

  • classpath 'com.android.tools.build:gradle:2.0.0-alpha2' 呢??

标签: android gradle configuration twitter-fabric build-tools


【解决方案1】:

这是我的 build.gradle(Module:app) 文件,我有一个可用的 CrashLytics,我的 project.gradle 中没有与织物相关的内容

buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
    }

    dependencies {
        classpath 'io.fabric.tools:gradle:1.+'
    }
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

repositories {
    maven { url 'https://maven.fabric.io/public' }
}

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

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        applicationId "com.ws.cs"
        minSdkVersion 14
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"

        ndk {
            abiFilters "armeabi-v7a", "x86"
        }
        packagingOptions {
            exclude "/lib/arm64-v8a/librealm-jni.so"
        }
    }


    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.google.code.gson:gson:2.2.2'
    compile 'io.realm:realm-android:0.82.1'
    compile('com.crashlytics.sdk.android:crashlytics:2.5.5@aar') {
        transitive = true;
    }


}

【讨论】:

    【解决方案2】:

    您必须从您的build.gradle (Project:NumenuApp) 中删除这些行。您使用了错误的文件来应用插件。

    apply plugin: 'com.android.application'
    apply plugin: 'io.fabric'
    

    在你的build.gradle (Module:app)中也移动这些行

    apply plugin: 'com.android.application'
    apply plugin: 'io.fabric'
    

    【讨论】:

    • 哇,惊喜,在我将 gradle 更新到 3.3 并将 androdi-gradle 更新到 2.3.0 之后,我遇到了完全相同的错误,但按照你的建议,我从应用程序中删除了 apply plugin: 'idea' 行(并且只留在模块中),现在它正在编译!
    【解决方案3】:

    请检查您的 app.gradle 是否存在

    buildToolsVersion "25.0.3"

    例子

    android {
        compileSdkVersion 25
        buildToolsVersion "25.0.3"
        defaultConfig {
            applicationId "kc.care.task"
            minSdkVersion 20
            targetSdkVersion 25
            versionCode 23
            versionName "3.7"
            multiDexEnabled = true
            testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
            vectorDrawables.useSupportLibrary = true
        }
    

    【讨论】:

      猜你喜欢
      • 2018-12-29
      • 1970-01-01
      • 2017-12-07
      • 2019-06-25
      • 2016-09-19
      • 1970-01-01
      • 1970-01-01
      • 2013-06-02
      • 2021-10-03
      相关资源
      最近更新 更多