answers inline

On Fri, Mar 21, 2014 at 1:28 AM, <[email protected]> wrote:

>
> android {
>     compileSdkVersion 17
>     buildToolsVersion "19.0.3"
>
>     buildTypes{
>             debug{
>             packageNameSuffix ".debug"
>             }
>
>             internal.initWith(buildTypes.debug)
>             internal{
>                 packageNameSuffix ".internal"
>             }
>          }
>      sourceSets {
>         main {
>             manifest.srcFile 'AndroidManifest.xml'
>             java.srcDirs = ['src']
>             resources.srcDirs = ['src']
>             aidl.srcDirs = ['src']
>             renderscript.srcDirs = ['src']
>             res.srcDirs = ['res']
>             assets.srcDirs = ['assets']
>             }
>
>          debug {
>                 manifest.srcFile 'debug/AndroidManifest.xml'
>                 res.srcDirs = ['debug/res']
>             }
>
>             internal{
>                 manifest.srcFile 'internal/AndroidManifest.xml'
>                 res.srcDirs = ['internal/res']
>             }
>
>         }
>     defaultConfig {
>         minSdkVersion 15
>         targetSdkVersion 19
>         versionName "dev"
>         versionCode  1
>
>     }
>  *  android.applicationVariants.all { variant ->*
>
> *        def oldFile = variant.packageApplication.outputFile;*
> *        def newFile =  appName + "-" + variant.name <http://variant.name>
> + "-v" + variant.config.versionName + "(" + variant.config.versionCode +
> ")"+ ".apk"*
> *        variant.packageApplication.outputFile = new File(oldFile.parent,
> newFile)*
>
> *    }*
>
> }
>
>  Note : i changed the it to ,
>
> android.variantFilter { variant ->
>                 flavor = variant.getDefaultConfig().versionName
>                 code = variant.getDefaultConfig().versionCode
>                 type = variant.getBuildType().name
>
>                 def oldFile = variant.outPath;
>                 def newFile =  appName + "-" + flavor + "-v" + type+ "(" +
> code +")"+ ".apk"
>                  variant.outputFile = new File(oldFile.parent, newFile)
>

I think you are confused about the variant object received in this closure.
It is not the same as the one received when looping on the
applicationVariants.

The release notes says the only method you can call are:

   - public void setIgnore(boolean ignore);
   - @NonNull public ProductFlavor getDefaultConfig();
   - @NonNull public BuildType getBuildType();
   - @NonNull public List<ProductFlavor> getFlavors();

(and BTW getDefaultConfig() is really pointless and will go away since you
can get it through project.android.getDefaultconfig()).

What this means is that calling variant.outputFile doesn't work because
that property doesn't exist.
You shouldn't replace applicationVariants by variantFilter, they are for
completely different needs.

The former allows you to tweak the generated variant, including its
outputfile. The latter is called *before* the variant is actually created,
with the data used to create it (which build type, which flavors), and
allow you to say "Nope, I don't want this variant).

setIgnore(true) is really this only action you can take in vaiantFilter.



>             }
>
>
> But error on oldFile = variant.outPath;
> no such property.
>
>
> Thanks in Advance!
>
> On Thursday, 20 March 2014 21:26:05 UTC+5:30, Xavier Ducrohet wrote:
>>
>> The variant filter only indicates whether the variant will be created. It
>> should not impact modifying the variant itself.
>>
>> You can provide you build.gradle so that we can look at it? We only need
>> the variantFilter closure and the applicationVariants.all closure.
>>
>>
>>  --
> 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.

Reply via email to