Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: [MS-229, MS-230] upgrade android config automation #602

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 6 additions & 23 deletions apps/wallet/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -160,30 +160,13 @@ android {
}
}

// applicationVariants are e.g. debug, release
applicationVariants.all { variant ->
def googleServiceMaker = "prepare${variant.name.capitalize()}GoogleServices"
task(googleServiceMaker, type: Copy) {
def fileName = variant.name.toLowerCase().contains("release") ? "google-services-prod.json" : "google-services-dev.json"
from "./"
include fileName
rename(fileName, "google-services.json")
into "./"
}
variant.assemble.dependsOn googleServiceMaker

variant.outputs.each { output ->
// For each separate APK per architecture, set a unique version code as described here:
// https://developer.android.com/studio/build/configure-apk-splits.html
// Example: versionCode 1 will generate 1001 for armeabi-v7a, 1002 for x86, etc.
def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4]
def abi = output.getFilter(OutputFile.ABI)
if (abi != null) { // null for the universal-debug, universal-release variants
output.versionCodeOverride =
defaultConfig.versionCode * 1000 + versionCodes.get(abi)
}

afterEvaluate {
task("copyGoogleServicesJson", type: Exec) {
print(project.gradle.startParameter.taskNames)
def environment = project.gradle.startParameter.taskNames.any { it.contains("Release") } ? "production" : "development"
commandLine('bash', '-c', "cp -r google-services-${environment}.json google-services.json")
}
preBuild.dependsOn "copyGoogleServicesJson"
}
}

Expand Down
Loading