Do you mean Android studio complains or the actual build fails?
I have a warning for that field too but it works perfectly anyway.
Cheers,
Stefan
On Wednesday, June 11, 2014 10:11:06 AM UTC+1, Jean-Michel Cazaux wrote:
>
> Hi Stephan,
> I have pasted your code in the android section of my build file, but it
> complains it does not know applicationVariants...
>
> Here iss my build file :
>
> apply plugin: 'android'
>
> android {
>
> /*
> buildVariants.each { variant ->
>
> apk = variant.packageApplication.outputFile;
>
> if (variant.buildType.name == "release") {
> newName = apk.name.replace(".apk", "-v" +
> defaultConfig.versionName + "-release.apk");
> } else {
> newName = apk.name.replace(".apk", "-v" +
> defaultConfig.versionName + "-beta.apk");
> }
>
> newName = newName.replace("-" + variant.buildType.name, "");
>
> variant.packageApplication.outputFile = new File(apk.parentFile,
> newName);
> if (variant.zipAlign) {
> variant.zipAlign.outputFile = new File(apk.parentFile,
> newName.replace("-unaligned", ""));
> }
>
> */
> signingConfigs {
> release {
> storeFile file("../r.keystore")
> storePassword "*****"
> keyAlias "*****"
> keyPassword "******"
> }
>
> }
>
> compileSdkVersion 19
> buildToolsVersion '19.1.0'
> defaultConfig {
> applicationId 'biz.****.android'
> minSdkVersion 14
> targetSdkVersion 19
> versionCode 0
> versionName '1.0.0.DEV'
> }
>
> buildTypes {
> release {
> runProguard false
> proguardFiles getDefaultProguardFile('proguard-android.txt'), '
> proguard-rules.pro'
> signingConfig signingConfigs.release
> }
> }
>
>
> productFlavors {
> }
>
> packagingOptions {
> exclude 'META-INF/LICENSE'
> exclude 'META-INF/NOTICE'
> }
>
> applicationVariants.all { variant ->
>
> def apk = variant.outputFile;
> def newName;
>
> // newName = apk.name.replace(".apk", "-v" +
> defaultConfig.versionName + "-" + variant.buildType.name.toUpperCase() +
> ".apk");
> if (variant.buildType.name == "release") {
> newName = apk.name.replace(".apk", "-v" +
> defaultConfig.versionName + "-release.apk");
> } else {
> newName = apk.name.replace(".apk", "-v" +
> defaultConfig.versionName + "-beta.apk");
> }
>
> // newName = newName
> // .replace("-" + variant.buildType.name, "")
> // .replace(project.name, "MyCoolCompany-MyGreatProduct");
>
> variant.outputFile = new File(apk.parentFile, newName);
>
> if (variant.zipAlign) {
> variant.outputFile = new File(apk.parentFile,
> newName.replace("-unaligned", ""));
> }
>
> logger.info('INFO: Set outputFile to ' + variant.outputFile + "
> for [" + variant.name + "]");
> }
> }
>
> dependencies {
> compile fileTree(dir: 'libs', include: ['*.jar'])
>
> /* Utilities & compatibility */
> compile 'org.apache.commons:commons-lang3:3.3.1'
> compile "com.android.support:support-v4:19.1.+"
>
> /* Car systems Common Library */
> compile project(':CommonsDroid')
>
> /* JSon tests */
> compile 'com.fasterxml.jackson.core:jackson-databind:2.4.0-rc3'
> compile 'com.google.code.gson:gson:1.7.2'
>
> /* ORM */
> compile 'com.j256.ormlite:ormlite-android:4.45'
>
>
>
>
> }
>
> Thank you all for your help,
>
> JM
>
>
> Le mercredi 11 juin 2014 09:00:27 UTC+2, Stefan Hoth a écrit :
>>
>> Hi Jean-Michel,
>>
>> sorry for the late reply. My current configuration looks like this and
>> still works https://gist.github.com/stefanhoth/faedeb4c58615992937d
>>
>> Hope that helps. If not, please do as Xavier says and post the exact
>> error messages.
>>
>> Cheers,
>> Stefan
>>
>>
>>
>> On Tuesday, June 10, 2014 9:35:38 AM UTC+1, Jean-Michel Cazaux wrote:
>>>
>>> Some help on this would really be much apopreciated ;)
>>>
>>> JM
>>>
>>> Le mardi 3 juin 2014 19:52:39 UTC+2, Jean-Michel Cazaux a écrit :
>>>>
>>>> Hi there,
>>>> I am trying to achieve teh same thing (renaming the apk file), but it
>>>> seems the sample code does not work anymore with a recent Android plugin...
>>>>
>>>> Both variant.packageApplication.outputFile and variant.outputFile are
>>>> erroring out.
>>>>
>>>> Any pointers to get this working on the last android plugin version ?
>>>> Has it been replaced by something else ?
>>>>
>>>> Many thanks in advance,
>>>> JM
>>>>
>>>>
>>>> Le jeudi 11 avril 2013 13:59:36 UTC+2, Stefan Hoth a écrit :
>>>>>
>>>>> Hi again,
>>>>>
>>>>> I was trying to get the version number of the
>>>>> "installMyFlavorRelease"-build. I was trying to modify the outputFile
>>>>> property in build variants but this is read only.
>>>>>
>>>>> My prefered output format would be
>>>>> <projectname>-<flavor>-<version>-<build type>.apk
>>>>>
>>>>> How can I do this?
>>>>>
>>>>> - Stefan
>>>>>
>>>>
--
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.