Configure the Build Environment
To leverage FCM, you need to configure your project to use the libraries provided by the Google Play services.
Open the build.gradle file in the project root directory and add
classpath 'com.google.gms:google-services:3.0.0' in the buildscript/dependencies.
The file should be now like this:
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
3.0.0 is the latest working version at the time of updating this document. If the newer version is available, you should be able to set it with no problem (but you might get a conflict error with the
play-services-gcm set in the next step). You can also specify
+ to apply the latest version, but note that this might put some unexpected updates in your project.
Open the build.gradle file located under the build target module (i.e., under the app directory by default) and edit the file as follows:
compilelines in the dependencies section.
apply plugin: 'com.google.gms.google-services'at the root level.
The configuration to be added depends on the version of your Android Studio. The file should be now like this:
9.6.1 is the latest working versionat the time of updating this document. If the newer version is available, you should be able to set it with no problem (just like the
play-services will be used in a process to check if the Google Play services exist on the device. Such a process is unnecessary in using the FCM feature only but the Firebase documentation recommends checking the existence of the services.
dependencies section includes the
firebase-messaging entry if you modify build.gradle according to the instruction on the Firebase console.
Confirm the app directory of the project contains google-services.json. This file has been copied to the directory in the step described in Create a Firebase Project.
When you are done with the above configurations, click the "Sync Now" on the top of the screen to reflect the changes. Now the libraries are automatically downloaded and referenced from the program.
This is all for the setting. Let us move to the next step: Configure the Manifest File.
|<< Configure Kii Cloud
|Configure the Manifest File >>