简体   繁体   中英

buildToolsVersion is not specified, all “apply plugin: xxxx ” is in app/build.gradle

my module build.gradle

apply plugin: 'com.android.application'

model {
    android {
        // 编译SDK的版本
        compileSdkVersion = 23

        // build tools的版本
        buildToolsVersion = "23.0.3"

        //useLibrary = 'org.apache.http.legacy'

        defaultConfig.with {
            // 应用的包名
            applicationId = "com.example.administrator.design"
            minSdkVersion.apiLevel = 15
            targetSdkVersion.apiLevel = 23
            versionCode = 1
            versionName = "1.0"
        }

        tasks.withType(JavaCompile) {
            //指定编译JDK版本
            sourceCompatibility = JavaVersion.VERSION_1_7
            targetCompatibility = JavaVersion.VERSION_1_7
        }

    }

    android.ndk {
        moduleName = "test"
        ldLibs += "log"
        abiFilters += "armeabi"
        abiFilters += "armeabi-v7a"
        abiFilters += "x86"
    }

    android.productFlavors {
        create("arm7") {
            ndk.abiFilters.add("armeabi-v7a")
        }
        create("arm8") {
            ndk.abiFilters.add("arm64-v8a")
        }

    }


    android.buildTypes {
        release {
            // 是否进行混淆
            minifyEnabled = false
            // 混淆文件的位置
            //proguardFiles  getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

            proguardFiles += file('proguard-android.txt')
            proguardFiles += file('proguard-rules.pro')

            //resValue "string", "facebook_app_id", '"597651723652854"'

        }

    }

}

dependencies {

    compile fileTree(include: ['*.jar'], dir: 'libs')
    //testCompile 'junit:junit:4.12'
    compile 'org.xutils:xutils:3.3.20' 

                ...

}

my project build.gradle

buildscript {
    repositories {
        jcenter()
        //mavenCentral()
    }
    dependencies {

        classpath 'com.android.tools.build:gradle:2.0.0'

    }
}

allprojects {
    repositories {
        jcenter()
    }
}

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

gradle wrapper

#Mon Mar 28 16:31:26 CST 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip

if I use "com.android.tools.build:gradle:0.20" in project build.gradle, and make some according changes it just works fine, But I want the new feature instant, run I have googled almost one afternoon.

Looks like you used an experimental gradle plugin version. The stable version 2.0.0 and the experimental version have some differences regarding the notation in the build.gradle file.

For example the android block needs to be outside the model block. And some attribute specifications are slightly different. Have a look at the Experimental Gradle Plugin User Guide , especially the red highlighted parts in the build.gradle example file.

Also I'm not really sure, but the non-experimental version still doesn't have full NDK support. Although it looks like the experimental version 0.6 does support the NDK as well as Instant Run, so you might use the version 0.6 instead of 2.0.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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