Doing
applicationVariants.all { variant ->
variant.buildType.buildConfigField "String", "NAME", "VALUE"
}
is a bad idea. Build types (and flavor objects) are global objects that are
shared with all the variants. What you were doing affected all variants.
This is why we moved to make the objects read-only. Basically once we start
building the variants we shouldn't allow touching these items as it can
have unintended consequences.
As for "I can't believe there's no interest in this function." we just are
busy with higher priority items right now. We triaged the bug and we'll get
to it eventually.
We also accept contributions, though we should figure out a design ahead of
time as there are some details about how variants are created from both
build type and flavor and how properties are handled when they exist in
both the build type and the flavor (which is what
https://code.google.com/p/android/issues/detail?id=64094 has to handle)
On Fri, Nov 14, 2014 at 7:59 AM, Bryan Herbst <[email protected]> wrote:
> 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.
>
--
Xavier Ducrohet
Android SDK Tech Lead
Google Inc.
http://developer.android.com | http://tools.android.com
Please do not send me questions directly. Thanks!
--
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.