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

jue*_*n d 4 java git android gradle

我想将此拾色器包含在我的Android Studio项目中.

所以我把它检查到一个本地文件夹,用Android Studio中的"New-> Import Module Dialog"将它添加到我的项目中.

然后我将这两行添加到我的app.gradle文件中

apply plugin: 'com.android.application'
...
compile project(':colorpicker')
Run Code Online (Sandbox Code Playgroud)

这是完整的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')
}
Run Code Online (Sandbox Code Playgroud)

但我一直在收到错误

错误:原因:未指定buildToolsVersion.

如果我没有将第一行添加到gradle文件(完全像颜色选择器描述所说的那样),那么我得到了

错误:(3,0)无法在类型为org.gradle.api.Project的项目':app'上找到参数[build_xxxxx]的方法android().

怎么解决?

Pav*_*ngh 9

按照步骤 :

打开build.gradle颜色选择器模块的文件

在此输入图像描述

所以在你的情况下将这些行添加到模块的build.gradle文件中colorpicker

compileSdkVersion 24
buildToolsVersion '24.0.2'
Run Code Online (Sandbox Code Playgroud)