From 52a63a489fd4147343734c528c43b268bfa00e1f Mon Sep 17 00:00:00 2001 From: "Loren M. Lang" Date: Sun, 30 Aug 2020 11:51:38 -0700 Subject: [PATCH] Allow the API key to be customized per-environment with local.properties It will default to ge0rg's production signing key if it's not included in local.properties --- build.gradle | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index afcf308..c743282 100644 --- a/build.gradle +++ b/build.gradle @@ -57,6 +57,16 @@ def versionCodeDate() { return new Date().format("yyyyMMdd00").toInteger() } } + +def mapsApiKey() { + Properties properties = new Properties() + try { + properties.load(project.rootProject.file('local.properties').newDataInputStream()) + } catch(Exception ex) {} + // the default google_maps_key is restricted to ge0rg's signing keys and can't be used by other builds! + properties.getProperty('mapsApiKey', "AIzaSyA12R_iI_upYQ33FWnPU_8GlMKrEmjDxiQ") +} + android { compileSdkVersion 28 defaultConfig { @@ -68,8 +78,7 @@ android { resValue "string", "build_date", "$build_date" resValue "string", "build_version", "$build_version" - // the google_maps_key is restricted to ge0rg's signing keys and can't be used by other builds! - resValue "string", "google_maps_key", "AIzaSyA12R_iI_upYQ33FWnPU_8GlMKrEmjDxiQ" + resValue "string", "google_maps_key", mapsApiKey() } useLibrary 'org.apache.http.legacy' compileOptions {