android - 使用 GoogleServices 插件时忽略 Gradle ArchivesBaseName

标签 android gradle

我经常使用 archivesbasename 重命名我的输出 apk,但由于使用了 google-services 插件,它被忽略了。我能做些什么来让它再次工作吗?

在下面附上我的完整 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
}

项目级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"
      }
  }
}

最佳答案

这对我停止了 android gradle 插件版本 1.3.0 使用 1.3.1 解决它。 类路径 'com.android.tools.build:gradle:1.3.1'

在您的应用程序的 build.gradle 中,您可能有这个。

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

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

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

关于android - 使用 GoogleServices 插件时忽略 Gradle ArchivesBaseName,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30954046/

相关文章:

android - 是否可以从 WebView 使用 Web 蓝牙?

Android 覆盖显式 Intent

java - 没有值插入时按钮 onclick 崩溃

spring-mvc - Spring Boot 执行器信息

maven - gradle 不是像 Maven 有 m2 那样有自己的仓库吗?

java - 由于 Android 消息 `Viewing full screen, To exit, swipe down from the top`,Espresso 测试失败

android - org.apache.http.NoHttpResponseException : The target server failed to respond

spring-boot - 如何使用gradle为as400 db2制作spring boot Web服务?

android - Google checkstyle 配置在 Android 项目上失败

Android 库针对 JDK 8 进行编译