1.进入官网
https://console.firebase.google.com/
登录后进入控制台
2.点击-添加项目
3.输入项目名称
4.点击-继续
5.选择账号 创建项目
6.等待项目创建
7.点击继续--然后点击android图标
8.输入包名-点击注册应用
9.下载google-service.json文件 然后点击下一步
10.添加SDK 然后点击下一步
Gradle 的 Google 服务插件会加载您刚刚下载的 google-services.json
文件。请修改您的 build.gradle 文件以使用该插件。
项目级 build.gradle(<项目>/build.gradle
):
buildscript {
repositories {
// Check that you have the following line (if not, add it):
google() // Google's Maven repository
}
dependencies {
...
// Add this line
classpath 'com.google.gms:google-services:4.3.8'
}
}
allprojects {
...
repositories {
// Check that you have the following line (if not, add it):
google() // Google's Maven repository
...
}
}
应用级 build.gradle(<项目>/<应用模块>/build.gradle
):
apply plugin: 'com.android.application'
// Add this line
apply plugin: 'com.google.gms.google-services'
dependencies {
// Import the Firebase BoM
implementation platform('com.google.firebase:firebase-bom:28.2.1')
// Add the dependency for the Firebase SDK for Google Analytics
// When using the BoM, don't specify versions in Firebase dependencies
implementation 'com.google.firebase:firebase-analytics'
// Add the dependencies for any other desired Firebase products
// https://firebase.google.com/docs/android/setup#available-libraries
}
11.点击前往控制台
如图: 点击箭头所示图标
12.进入后会展示如下:
至此,项目创建完成
附上地址链接:
文档地址:https://firebase.google.com/docs/ab-testing/?authuser=0
设置android客户端文档:
https://firebase.google.com/docs/cloud-messaging/android/client?authuser=0
具体使用请参考文档地址:
https://firebase.google.com/docs/cloud-messaging/android/client?authuser=0
对了 之前下载的google-service.json 到时候放在项目目录下
另附上FCM功能github地址: