找不到方法classpath() flutter

问题描述 投票:0回答:1
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
}

例外:here

flutter firebase gradle
1个回答
0
投票

classpath
不是声明依赖项的有效配置。

buildscript { ... }
块中,
classpath
将作为配置存在,以将依赖项添加到构建脚本以便在构建脚本代码中使用,尽管即使在那里使用它也是不好的做法。

如果您的代码需要依赖项,您可能需要使用

implementation
来代替。

我还建议切换到 Kotlin DSL。现在它是默认的 DSL,您可以立即获得类型安全的构建脚本,如果您搞乱了语法,您会收到实际上有用的错误消息,如果您使用 IntelliJ IDEA 或 Android Studio 等优秀的 IDE,那么您还会获得更好的 IDE 支持。

© www.soinside.com 2019 - 2024. All rights reserved.