Skip to content
Merged
Show file tree
Hide file tree
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
25 changes: 25 additions & 0 deletions bin/templates/project/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,28 @@ buildscript {
}

dependencies {
apply from: '../CordovaLib/cordova.gradle'

classpath 'com.android.tools.build:gradle:3.3.0'

if(cdvHelpers.getConfigPreference('GoogleServicesEnabled', 'false').toBoolean()) {
String defaultGoogleServiceVersion = '4.2.0'

/**
* Fetches the user's defined Google Services Plugin Version from config.xml.
* If the version is not set or invalid, it will default to the ${defaultGoogleServiceVersion}
*/
String googleServicesVersion = cdvHelpers.getConfigPreference('GoogleServicesVersion', defaultGoogleServiceVersion)
if(!cdvHelpers.isVersionValid(googleServicesVersion)) {
println("The defined Google Services plugin version (${googleServicesVersion}) does not appear to be a valid version. Falling back to version: ${defaultGoogleServiceVersion}.")
googleServicesVersion = defaultGoogleServiceVersion
}

// Create the Google Services classpath and set it.
String googleServicesClassPath = "com.google.gms:google-services:${googleServicesVersion}"
println "Adding classpath: ${googleServicesClassPath}"
classpath googleServicesClassPath
}
}
}

Expand Down Expand Up @@ -356,3 +377,7 @@ for (def func : cdvPluginPostBuildExtras) {
if (hasProperty('postBuildExtras')) {
postBuildExtras()
}

if (cdvHelpers.getConfigPreference('GoogleServicesEnabled', 'false').toBoolean()) {
apply plugin: 'com.google.gms.google-services'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my plugin when I do this, for some reason it needs to be the full path to the plugin, not just the string... I think that might have had something to do with being a subproject though

apply plugin: com.google.gms.googleservices.GoogleServicesPlugin

}
4 changes: 4 additions & 0 deletions framework/cordova.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ Version[] getAvailableBuildTools() {
.sort { a, b -> a.isHigherThan(b) ? -1 : 1 }
}

Boolean isVersionValid(version) {
return !(new Version(version)).isEqual('0.0.0')
}

String doFindLatestInstalledBuildTools(String minBuildToolsVersionString) {
def availableBuildToolsVersions
try {
Expand Down