找不到根项目上的参数的方法buildConfig()

时间:2018-12-17 13:20:51

标签: gradle

这是我的Gradle构建构建文件,但出现以下错误-

Could not find method buildConfig() for arguments [build_bkix1el12dgxkzcozxb0vbhet$_run_closure3@7b09d775] on root project 'test2' of type org.gradle.api.Project.

构建文件。

plugins {
    // Apply the java-library plugin to add support for Java Library
    id 'java-library'
    id 'de.fuerstenau.buildconfig' version '1.1.8' apply false
    id 'eclipse'
}

dependencies {
    // This dependency is exported to consumers, that is to say found on their compile classpath.
    api 'org.apache.commons:commons-math3:3.6.1'

    // This dependency is used internally, and not exposed to consumers on their own compile classpath.
    implementation 'com.google.guava:guava:23.0'

    // Use JUnit test framework
    testImplementation 'junit:junit:4.12'
}

// In this section you declare where to find the dependencies of your project
repositories {
    // Use jcenter for resolving your dependencies.
    // You can declare any Maven/Ivy/file repository here.
    jcenter()
    mavenLocal()    
    mavenCentral()
    maven { url "https://jitpack.io" }
}

buildConfig {
  packageName = "test2"
  clsName = "BuildConfig"
}

1 个答案:

答案 0 :(得分:0)

请参见

id 'de.fuerstenau.buildconfig' version '1.1.8' apply false

您没有应用此插件(apply false),因此未创建扩展名buildConfig,这说明了收到的错误。

如果要应用和使用/配置此插件,则应在插件声明中删除apply false选项。