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'