无法访问“委托”:在“ Build_gradle”中它是不可见的(超类型中的私有)

时间:2019-10-21 10:05:30

标签: android gradle-kotlin-dsl

Android Studio 3.5

build.gradle:

buildTypes {
   release {
 }
 debug {
    configBuildType(delegate, DEBUG_APP_NAME, DEBUG_APP_ID_SUFFIX, DEBUG_API_BASE_URL)
}
}

def configBuildType(buildType, appName, appIdSuffix, apiBaseURL) {
    buildType.resValue("string", "app_name", appName)
    buildType.applicationIdSuffix(appIdSuffix)
    buildType.buildConfigField("String", "API_BASE_URL", apiBaseURL)
}

,并且此成功在 build.gradle 中起作用。

但是当我将其转换为 build.gradle.kts

buildTypes {
        getByName("release") {
        }
        getByName("debug") {
            configBuildType(delegate, DEBUG_APP_NAME, DEBUG_APP_ID_SUFFIX)
        }
    }
} 

fun configBuildType(buildType: com.android.build.gradle.internal.dsl.BuildType, appName: String, appVersion: String) {
    buildType.resValue("string", "application_name", appName)
    buildType.buildConfigField("String", "APP_VERSION", appVersion)
}

此行出现错误:

configBuildType(delegate, DEBUG_APP_NAME, DEBUG_APP_ID_SUFFIX)


Cannot access 'delegate': it is invisible (private in a supertype) in 'Build_gradle'

0 个答案:

没有答案