使用GoogleServices插件时,Gradle ArchivesBaseName被忽略

时间:2015-06-20 12:30:52

标签: android gradle

我经常使用archivesbasename重命名我的输出apk,但由于使用了google-services插件,因此会被忽略。有什么我可以做的让这个再次起作用。

附上我的完整build.gradle,感谢任何指示。

var regExp = @"(\[RAND\])(\w|\s|\d)*(\[/RAND\])";
var res = Regex.Replace(str, regExp, match =>
{
       // suffle the and return result
       // the return string replaced with occuring rand area
       // for example with suffle algorithms
       return "Randomized";
 });

项目级别build.gradle

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'

project.archivesBaseName = "MyApp";

android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1"

    defaultConfig {
        applicationId "org.codechimp.myapp"
        versionCode 205
        versionName "2.4"
        minSdkVersion 14
        targetSdkVersion 22
    }

    productFlavors {
        prod {            
        }

        dev {
            versionName = android.defaultConfig.versionName + " dev"
        }
    }

    signingConfigs {
        debug {
            storeFile file("debug.keystore")
            storePassword "android"
            keyAlias "androiddebugkey"
            keyPassword "android"
        }
        release }

    buildTypes {
        debug {
            debuggable true
            signingConfig signingConfigs.debug
        }
        release {
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.release
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:support-annotations:22.2.0'
    compile 'com.google.android.gms:play-services-drive:7.5.0'
    compile 'com.google.android.gms:play-services-plus:7.5.0'
    compile 'com.google.android.gms:play-services-gcm:7.5.0'
    compile 'com.google.android.gms:play-services-ads:7.5.0'
    compile 'com.google.android.gms:play-services-identity:7.5.0'
    compile 'com.android.support:support-v4:22.2.0'
    compile 'com.android.support:appcompat-v7:22.2.0'
    compile 'com.android.support:recyclerview-v7:22.2.0'
    compile 'com.afollestad:material-dialogs:0.6.2.4'
    compile 'com.google.code.gson:gson:2.3'
    compile 'com.github.andrew-codechimp:androidutils:1.19'
}

def Properties props = new Properties()
props.load(new FileInputStream(file('signing.properties')))

if (props.containsKey('STORE_FILE') && props.containsKey('STORE_PASSWORD') &&
        props.containsKey('KEY_ALIAS') && props.containsKey('KEY_PASSWORD')) {
    android.signingConfigs.release.storeFile = file(props['STORE_FILE'])
    android.signingConfigs.release.storePassword = props['STORE_PASSWORD']
    android.signingConfigs.release.keyAlias = props['KEY_ALIAS']
    android.signingConfigs.release.keyPassword = props['KEY_PASSWORD']
} else {
    android.buildTypes.release.signingConfig = null
}

1 个答案:

答案 0 :(得分:6)

使用1.3.1解析它时,我停止使用android gradle插件版本1.3.0。 classpath 'com.android.tools.build:gradle:1.3.1'

在app的build.gradle中你可能有这个。

android {
    //...
    defaultConfig {
        //...
        archivesBaseName = "myprojectname_v${versionName}_${versionCode}"
    }
    //...
}

如果您想根据构建类型更改APK名称。

android {
    //...
    buildTypes {
        special {
            //...
            archivesBaseName = "myprojectname_special_v${versionName}_${versionCode}"
        }
    }
    //...
}