From 5422e25d415f77e62486d1fde839ebdffb6de523 Mon Sep 17 00:00:00 2001 From: Joshua Quick Date: Tue, 14 Apr 2020 19:13:32 -0700 Subject: [PATCH] feat(android)(9_0_X): add "google-services.json" support (#11514) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore(android): handle google-services.json * chore: add gradle plugin condition * chore(android): add google-services.json support to app template Co-authored-by: hansemannn Co-authored-by: Hans Knöchel Co-authored-by: ssekhri --- android/build.gradle | 1 + android/cli/commands/_build.js | 7 +++++++ android/templates/build/app.build.gradle | 5 +++++ android/templates/build/root.build.gradle | 1 + 4 files changed, 14 insertions(+) diff --git a/android/build.gradle b/android/build.gradle index a3187d5da9d..82d7b518f7c 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -13,6 +13,7 @@ buildscript { jcenter() } dependencies { + classpath 'com.google.gms:google-services:4.3.3' classpath 'com.android.tools.build:gradle:3.6.0' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } diff --git a/android/cli/commands/_build.js b/android/cli/commands/_build.js index 3518e8f6897..9936b71e998 100644 --- a/android/cli/commands/_build.js +++ b/android/cli/commands/_build.js @@ -2251,6 +2251,13 @@ AndroidBuilder.prototype.generateAppProject = async function generateAppProject( } } + const googleServicesFile = path.join(this.projectDir, 'platform', 'android', 'google-services.json'); + if (await fs.exists(googleServicesFile)) { + afs.copyFileSync(googleServicesFile, path.join(this.buildAppDir, 'google-services.json'), { + logger: this.logger.debug + }); + } + // Copy Titanium project's "./platform/android" directory tree to "app" project's "./src/main". // Android build tools auto-grabs folders named "assets", "res", "aidl", etc. in this folder. // Note: Our "build.gradle" is configured to look for JAR/AAR files here too. (Needed by hyperloop.) diff --git a/android/templates/build/app.build.gradle b/android/templates/build/app.build.gradle index 43663f6ddd7..718dc3733c0 100644 --- a/android/templates/build/app.build.gradle +++ b/android/templates/build/app.build.gradle @@ -1,6 +1,11 @@ apply plugin: 'com.android.application' +// Apply the Google Services plugin if included +if (file("${projectDir}/google-services.json").exists()) { + apply plugin: 'com.google.gms.google-services' +} + repositories { <% if (mavenRepositoryUrls) { for (let nextUrl of mavenRepositoryUrls) { %> maven { url '<%- nextUrl %>' } diff --git a/android/templates/build/root.build.gradle b/android/templates/build/root.build.gradle index a80e788f614..701340b1396 100644 --- a/android/templates/build/root.build.gradle +++ b/android/templates/build/root.build.gradle @@ -8,6 +8,7 @@ buildscript { } dependencies { classpath 'com.android.tools.build:gradle:3.6.0' + classpath 'com.google.gms:google-services:4.3.3' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } }