I was developing a small project ( app for Android) in Cordova ( https://cordova.apache.org ), and this project one of the requirements was to send notifications push ( push notifications ) to the application through the Service Cloud Messaging Google Firebase ( https://console.firebase.google.com ).
The procedure for implementing this task is relatively simple. Just access the Google Firebase console, create a new project, enter the information (name, package, etc …), configure it for Android and finally download the file google-services.json
This file, in the case of a Cordova project, must be inserted into the folder “platforms/android/app“.
In addition, it is necessary to import the “phonegap-plugin-push” library for the project.
That done, I tried to build the app, but I ended up with the following error:
Execution failed for task ':app:processDebugGoogleServices' |
This error is followed by the following message:
File google-services.json is missing. The Google Services Plugin cannot function without it. |
This error is caused due to the absence of a dependency in the Gradle configuration file (Gradle is a Build Tool responsible for “building” the app from the Cordova project).
To solve, just go to the folder “platforms/android/app” and open the file “build.gradle“.
In this file, it is necessary to locate the line “dependencies“. Within the {} of the “dependencies“, you must insert the following classpath
classpath 'com.google.gms: google-services: 3.0.0' |
That way, your code will look something like this:
dependencies {
apply from: '../CordovaLib/cordova.gradle'
classpath 'com.android.tools.build:gradle:4.0.0'
classpath 'com.google.gms: google-services: 3.0.0'
.
.
.
} |
After inserting the classpath, save the file and try to run again. It will work!!!
Any questions leave your comment
See you!
Execution failed for task ‘:app:processDebugGoogleServices’.
> org.gradle.api.file.FileCollection.getElements()Lorg/gradle/api/provider/Provider;
* Try:
Run with –stacktrace option to get the stack trace. Run with –info or –debug option to get more log output. Run with –scan to get full insights.
it brings that and i have added the classpath
Hi Godwin,
Are you trying to run is on cordova?
If it is, run the command “cordova run android -stacktrace” to display more information about the error.
=)