Gradle ArchivesBaseName在使用GoogleServices插件时被忽略 [英] Gradle ArchivesBaseName ignored when using GoogleServices plugin

查看:1114
本文介绍了Gradle ArchivesBaseName在使用GoogleServices插件时被忽略的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I've regularly used the archivesbasename to rename my output apk's but since using the google-services plugin it is being ignored. Is there anything I can do to get this working again.

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

Attached my full build.gradle below, be grateful for any pointers.

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
}

项目级别build.gradle

Project level build.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
  repositories {
      jcenter()
  }
  dependencies {
      classpath 'com.android.tools.build:gradle:1.2.3'
      classpath 'com.google.gms:google-services:1.3.0-beta1'

      // NOTE: Do not place your application dependencies here; they belong
      // in the individual module build.gradle files
  }
}

allprojects {
  repositories {
      jcenter()
      maven {
          url "https://jitpack.io"
      }
  }
}

推荐答案

使用1.3.1解决了这个问题,使用Android Gradle插件1.3.0版停止工作。
classpath'com.android.tools.build:gradle:1.3.1'

This stopped working for me with android gradle plugin version 1.3.0 using 1.3.1 resolves it. classpath 'com.android.tools.build:gradle:1.3.1'



Inside your build.gradle for the app you might have this.

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

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

If you want to change the APK name based on build type.

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

这篇关于Gradle ArchivesBaseName在使用GoogleServices插件时被忽略的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆