android – 无法在额外的属性扩展上获取属性’compileSdkVersion’,因为它不存在

有人请帮帮我….

无法在额外的属性扩展上获取属性’compileSdkVersion’,因为它在
android studio中不存在. 最佳答案 转到“项目文件”视图,然后打开构建gradle.

你会发现这样的东西

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

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.1'


        // 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
}

你必须添加这个定义:

ext {
    compileSdkVersion = 23
    buildToolsVersion = "23.0.1"
    targetSdkVersion = 21
}
点赞