2015-06-20 26 views
11

我經常使用archivesbasename來重命名我的輸出apk,但是由於使用google-services插件,它被忽略。有什麼我可以做的,讓這個工作再次。使用GoogleServices插件時忽略了Gradle ArchivesBaseName

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

您正在使用哪個gradle插件版本? – Logain

+0

版本1.2.3,增加了項目級別build.gradle,你可以看到它沒有做任何特別的事情。 – CodeChimp

回答

6

該停止使用1.3.1解決了它與Android插件的Gradle版本1.3.0爲我工作。 classpath '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}" 
     } 
    } 
    //... 
} 
+0

修復它,等待他們修復它,但至少我現在可以刪除我的哈克代碼。感謝你的回答。 – CodeChimp

+1

我更新到1.3.1,它仍然無法正常工作。有任何想法嗎? – nadavfima

+0

我已經更新了我的答案以包含其使用示例。 – Simon