build.gradle 变化

新版Android studio新建工程​build.gradle默认如下:

// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
    id 'com.android.application' version '7.2.1' apply false
    id 'com.android.library' version '7.2.1' apply false
}

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

比如我们需要在项目根目录引入时,该如何下手,其实很简单直接在plugins 上方添加即可

classpath 'com.......'

方案:注意buildscript 需要放在plugins上方,否则会报错。 

buildscript {
    dependencies {
        classpath 'com....'
    }
}

plugins {
    id 'com.android.application' version '7.2.1' apply false
    id 'com.android.library' version '7.2.1' apply false
}

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

猜你喜欢

转载自blog.csdn.net/shi450561200/article/details/132819730