简体   繁体   English

将模块从GIT添加到Android Studio会引发“未指定buildToolsVersion”错误

[英]Add Module from GIT to Android Studio throws “buildToolsVersion is not specified” error

I want to include this Color Picker into my Android Studio project. 我想将此拾色器包含在我的Android Studio项目中。

So I checked it out into a local folder, added it to my project with the "New->Import Module Dialog in Android Studio. 所以我把它检查到一个本地文件夹,用Android Studio中的“New-> Import Module Dialog”将它添加到我的项目中。

Then I added those 2 lines to my app.gradle file 然后我将这两行添加到我的app.gradle文件中

apply plugin: 'com.android.application'
...
compile project(':colorpicker')

Here is the complete gradle file 这是完整的gradle文件

apply plugin: 'com.android.application'

android {
    compileSdkVersion 24
    buildToolsVersion '24.0.2'

    defaultConfig {
        applicationId "com.mydomain.myapp"
        minSdkVersion 17
        targetSdkVersion 24
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

repositories {
    maven { url "https://jitpack.io" }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile fileTree(include: ['dtp_library'], dir: 'libs')
    compile project(':libs:dtp_library')
    compile 'com.android.support:design:24.2.1'        
    compile project(':colorpicker')
}

But I keep getting the error 但我一直在收到错误

Error:Cause: buildToolsVersion is not specified. 错误:原因:未指定buildToolsVersion。

If I do not add the first line to the gradle file (do it exactly like the color picker description said) then I get 如果我没有将第一行添加到gradle文件(完全像颜色选择器描述所说的那样),那么我得到了

Error:(3, 0) Could not find method android() for arguments [build_xxxxx] on project ':app' of type org.gradle.api.Project. 错误:(3,0)无法在类型为org.gradle.api.Project的项目':app'上找到参数[build_xxxxx]的方法android()。

How to fix it? 怎么解决?

Follow the steps : 按照步骤 :

Open the build.gradle file of color picker module 打开颜色选择器模块的build.gradle文件

在此输入图像描述

so in your case add these lines to build.gradle file of colorpicker module 所以在你的情况下,将这些行添加到colorpicker模块的build.gradle文件中

compileSdkVersion 24
buildToolsVersion '24.0.2'

请把你的buildToolVersion放在双引号中

buildToolsVersion "23.0.2"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM