How to set variable according to gradle flavors

后端 未结 2 1690
我在风中等你
我在风中等你 2021-02-01 17:01

I want to pass a variable test that I set differently per flavor as a define to the NDK. But for some reason he always passes the value of the last flavor.

2条回答
  •  时光取名叫无心
    2021-02-01 17:51

    You can use buildConfigField

    productFlavors {
        demo {
            buildConfigField "int", "FOO", "1"
            buildConfigField "String", "FOO_STRING", "\"foo1\""
        }
        full {
            buildConfigField "int", "FOO", "2"
            buildConfigField "String", "FOO_STRING", "\"foo2\""
        }
    }
    

提交回复
热议问题