Hi Xavier, thank you for your reply.
I wasn't addressing you guys when I said "I can't believe there's no interest in this function." I was referring to the fact that no one was replying my post. :) I understand there are more urgent thing but I was hoping in some kind of workaround to achieve what I need while waiting for an official feature implementation. I was the one who opened the issue: https://code.google.com/p/android/issues/detail?id=73396 but felt like this kind of discussion was OT in the bug report. It is good news that now I can override values in the build type. Can I also override them in variants from the default? It would be good to be able to SELECTIVELY override, meaning that the build type should know the variant being build and be able to adapt. This is something missing completely, I figure it should work as android values: flavor-buildtype free-debug free-release pay-debug pay-release to address the specific combination both in the build file and in the directory structure... but I'm drifting away from my original request that was just: how do I obtain the "current" flavor to assign buildConfig and resConfig values in the gradle build file? Thanks. Daniele On Friday, November 14, 2014 6:56:23 PM UTC+1, Xavier Ducrohet wrote: > > 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] > <javascript:>> 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] <javascript:>. >> 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.
