这种语法可能有什么问题?我正在找不到Gradle DSL方法:“ buildConfigFields()”错误。

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.1"

    defaultConfig {
        applicationId "com.okason.drawingapp"
        minSdkVersion 16
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"


        def filesAuthorityValue = applicationId + ".files"

        //Now you can use ${filesAuthority} in your manifest
        manifestPlaceholders = [filesAuthority: filesAuthorityValue]

        //Now you can use BuildConfig.FILES_AUTHORITY in our code
        buildConfigFields "String", "FILES_AUTHORITY", "\"${filesAuthorityValue}\""
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

最佳答案

您应该使用buildConfigField而不是buildConfigFields

更改

//Now you can use BuildConfig.FILES_AUTHORITY in our code
buildConfigFields "String", "FILES_AUTHORITY", "\"${filesAuthorityValue}\""




//Now you can use BuildConfig.FILES_AUTHORITY in our code
buildConfigField "String", "FILES_AUTHORITY", "\"${filesAuthorityValue}\""


您确定buildConfigFields甚至退出吗?

关于android - Gradle BuildConfigFields语法,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/33585426/

10-12 00:25