resValue gradle error: Unsupported type “String” in “generated.xml”

后端 未结 1 771
旧巷少年郎
旧巷少年郎 2020-12-08 07:18

A few weeks ago I posted a question How to override resources depending on buildType. And just yesterday there was a gradle plugin release for android. Based on this post on

相关标签:
1条回答
  • 2020-12-08 07:38

    I solved adding the resources also in the defaultConfig block. For you it would be something like:

    android {
        defaultConfig {
            resValue "string", "RES_FOO", "RES FOO RELEASE"
        }
    
        buildTypes {
            debug{
                buildConfigField "String", "FOO", "\"FOO DEBUG\""
                resValue "string", "RES_FOO", "RES FOO DEBUG"
            }
            release {
                buildConfigField "String", "FOO", "\"FOO RELEASE\""
                resValue "string", "RES_FOO", "RES FOO RELEASE"
            }
        }
    }
    

    Please note that:

    • item type must be string and not String
    • item name must not contain spaces (as normal resource name)

    EDIT: Since 0.8.3 it should works fine just declaring the resValue in the build type block.

    0 讨论(0)
提交回复
热议问题