Created
June 6, 2015 08:18
-
-
Save tiwiz/b5fac29f4bacc3dfb0c9 to your computer and use it in GitHub Desktop.
Implementing Crashlytics on a multiflavour and multi-key environment
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
final File fabricFile = file("fabric.properties") | |
afterEvaluate { | |
android.applicationVariants.all { variant -> | |
final String variantName = variant.getName().capitalize() | |
final Task targetTask = tasks["process${variantName}Manifest"] | |
if (fabricTask != null) { | |
final Task generateFabricFile = task("generateFabricFile$variantName") { | |
doLast { | |
String fabricApiSecret = 'verySecretApiSecretForEveryoneGuessItsNotThatSecret' | |
String fabricApiKey = 'veryKeyApiKeyForEveryone' | |
if (variantName.equalsIgnoreCase("DifferentClientDebug") || variantName.equalsIgnoreCase("DifferentClientRelease")) { | |
fabricApiSecret = 'verySecretApiSecretForDifferentClient' | |
fabricApiKey = 'veryKeyApiKeyForDifferentClient' | |
} | |
if (fabricFile.exists()) { | |
println "Deleting previous configuration File for Fabric (variant: $variantName)" | |
fabricFile.delete() | |
} | |
println '*** FABRIC DATA ***' | |
println "apiSecret=$fabricApiSecret" | |
println "apiKey=$fabricApiKey" | |
println '*******************' | |
def commentMessage = "Autogenerated Fabric properties for Crashlytics" | |
ant.propertyfile(file: fabricFile, comment: commentMessage) { | |
entry(key: "apiSecret", value: fabricApiSecret) | |
entry(key: "apiKey", value: fabricApiKey) | |
} | |
} | |
} | |
targetTask.dependsOn generateFabricFile | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment