Skip to content

Commit

Permalink
feat(android): add "google-services.json" support (#11461)
Browse files Browse the repository at this point in the history
* chore(android): handle google-services.json

* chore: add gradle plugin condition

* chore(android): add google-services.json support to app template

Co-authored-by: Christopher Williams <chris.a.williams@gmail.com>
Co-authored-by: Joshua Quick <jquick@axway.com>
Co-authored-by: ssekhri <ssekhri@axway.com>
  • Loading branch information
4 people committed Apr 15, 2020
1 parent 11dff9d commit d04d9e9
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down
7 changes: 7 additions & 0 deletions android/cli/commands/_build.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.)
Expand Down
5 changes: 5 additions & 0 deletions android/templates/build/app.build.gradle
Original file line number Diff line number Diff line change
@@ -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 %>' }
Expand Down
1 change: 1 addition & 0 deletions android/templates/build/root.build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
Expand Down

0 comments on commit d04d9e9

Please sign in to comment.