Sounds good Xavier, thanks for the info.
On Wednesday, November 5, 2014 3:01:28 PM UTC-7, Xavier Ducrohet wrote:
>
> There's definitively some scoping restrictions that happens when you move
> stuff into a separate file.
>
> One thing you could do is make getBuildVersionName be an extra prop on
> the project. so in versions.gradle do something like:
>
> project.ext.getBuildVersionName = {}
>
> and then reference it like that in your build.gradle.
>
> There may be better ways to do this, but I think this one way works.
>
> On Wed, Nov 5, 2014 at 1:57 PM, Ray Hunter <[email protected]
> <javascript:>> wrote:
>
>> I have an application with about 5+ product flavors and I wrote a method
>> in an external script that will create the versionCode.
>>
>> Something similar to this:
>>
>> apply from: 'versions.gradle'
>>
>> android {
>>
>> productFlavors {
>> dev {
>> applicationId PACKAGE_NAME + ".dev"
>> versionCode getBuildVersionCode(dev.name)
>> versionName getBuildVersionName(dev.name)
>> }
>>
>> // additional flavors with the same method calls for the
>> versionCode and versionName
>> }
>>
>> }
>>
>> When I run gradle, even just clean, I get the following error:
>>
>> > Could not find method getBuildVersionCode() for arguments [dev] on
>> GroupableProductFlavorDsl_Decorated{name=dev, minSdkVersion=null,
>> targetSdkVersion=null, renderscriptTargetApi=null,
>> renderscriptSupportModeEnabled=null, renderscriptNdkModeEnabled=null,
>> versionCode=null, versionName=null, applicationId=null,
>> testApplicationId=null, testInstrumentationRunner=null,
>> testHandleProfiling=null, testFunctionalTest=null, signingConfig=null,
>> resConfig=null, mBuildConfigFields={}, mResValues={}, mProguardFiles=[],
>> mConsumerProguardFiles=[], mManifestPlaceholders={}}.
>>
>> This is using the following:
>>
>> Gradle 2.1 (wrapper)
>> Android Gradle Plugin 0.14.1
>>
>> If I move the method from the external script into my build script, then
>> it works.
>>
>> I am wondering if this is a bug or if there is a work around for
>> accessing the method in the external script or if there is a better way to
>> generate the versionCode or versionName.
>>
>>
>>
>>
>>
>> --
>> 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.