buildscript {
repositories{
google()
mavenCentral()
}
}
allprojects {
repositories {
google()
mavenCentral()
}
}
dependencies {
classpath 'com.google.gms:google-services:4.4.1'
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
tasks.register("clean", Delete) {
delete rootProject.buildDir
}
例外:
classpath
不是声明依赖项的有效配置。
在
buildscript { ... }
块中,classpath
将作为配置存在,以将依赖项添加到构建脚本以便在构建脚本代码中使用,尽管即使在那里使用它也是不好的做法。
如果您的代码需要依赖项,您可能需要使用
implementation
来代替。
我还建议切换到 Kotlin DSL。现在它是默认的 DSL,您可以立即获得类型安全的构建脚本,如果您搞乱了语法,您会收到实际上有用的错误消息,如果您使用 IntelliJ IDEA 或 Android Studio 等优秀的 IDE,那么您还会获得更好的 IDE 支持。