I previously avoided calling buildConfigField multiple times is by hooking
into applicationVariants.all like so:
applicationVariants.all { variant ->
variant.buildType.buildConfigField "String", "NAME", "VALUE"
}
Unfortunately as of version 0.14 of the Gradle plugin variant.buildType is
read-only, so this no longer works.
The "correct" solution is to use variant.mergedFlavor.buildConfigField.
However, that API doesn't exist yet. Progress for this feature is being
tracked in issue 67416 <http://stackoverflow.com/a/22511486/1253844>.
On Friday, November 14, 2014 3:42:38 AM UTC-6, Daniele Segato wrote:
>
> That's not the same.
>
> I know I can do the switch Java side but it's a completely different thing.
>
> If I use that to set API Keys etc. I don't want ALL OF THEM to be in the
> Java file. That will be compiled and packaged with the APK.
>
> I want to set it in the build file and have only 1 of the value in the
> APK. The one needed by that APK.
>
>
>
> On Friday, November 14, 2014 10:22:36 AM UTC+1, Avram Lyon wrote:
>>
>> The flavor names are already put in the BuildConfig by the Android plugin
>> itself, so you generally wouldn't need that.
>>
>> *Avram Lyon*
>> Android wrangler | Scopely, Inc.
>>
>> Refer The Smartest Person You Know And Pocket $7,000!
>> *Learn more: scopely.com/referrals
>> <http://www.scopely.com/referrals/?page=4>*
>>
>> On Fri, Nov 14, 2014 at 12:40 AM, Daniele Segato <[email protected]>
>> wrote:
>>
>>> I can't believe there's no interest in this function.
>>>
>>>
>>> On Wednesday, November 12, 2014 1:14:33 PM UTC+1, Daniele Segato wrote:
>>>>
>>>> Hi,
>>>>
>>>> I posted a feature request a while ago here:
>>>> https://code.google.com/p/android/issues/detail?id=73396
>>>>
>>>> which describe what I'd like to have.
>>>>
>>>> Since it had no reply I'm now writing here to know if there is some way
>>>> to achieve a similar result.
>>>>
>>>> Is there a way to write something like this:
>>>>
>>>> buildConfigField "String", "MY_VAR_NAME", getMyVarValue(
>>>> getCurrentFlavor());
>>>>
>>>> specifically I need the getCurrentFlavor() method so that my
>>>> function getMyVarValue can do all the switches needed.
>>>>
>>>> any way to achieve this?
>>>>
>>>> how do you handle that situation?
>>>>
>>>>
>>>> Thank you,
>>>> Daniele
>>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "adt-dev" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to [email protected].
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
--
You received this message because you are subscribed to the Google Groups
"adt-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.