// …
}
}
- 在Gradle 文件(通常是
app/build.gradle
)中,在文件末尾添加一行内容。
apply plugin: ‘com.android.application’
android {
// …
}
// 添加以下内容:
apply plugin: ‘com.google.gms.google-services’ // Google Play services Gradle plugin
第四步:将 Firebase SDK 添加到APP
在(应用级)Gradle 文件(通常是 app/build.gradle
)中,添加核心 Firebase SDK 的依赖项:
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.3’
}
}
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 {
// add the Firebase SDK for Google Analytics
implementation ‘com.google.firebase:firebase-analytics:17.2.2’
// add SDKs for any other desired Firebase products
// https://firebase.google.com/docs/android/setup#available-libraries
}
最后,按 IDE 中显示的栏中的“立即同步”:
-
同步您的应用以确保所有依赖项都具有必要的版本。
-
运行应用,向 Firebase 发送已成功集成 Firebase 的验证信息。
设备日志将显示说明初始化已完成的 Firebase 验证信息。如果我们是在具有网络访问权限的模拟器上运行应用,则 Firebase 控制台会通知说应用连接已完成。
第一步:下载数据集:
我这里使用的是使用 TensorFlow 的 flower-image 数据集,创建图像分类或标签模型,在训练了该模型后,将其用于应用程序中的设备上图像标签。
这个数据集又5种标签的雏菊,蒲公英,玫瑰,向日葵和郁金香花,这样后面的 app 就可以使用模型标识图像的标签之一。
下载花卉图像数据集。
第二步:上传和训练数据集:
转到 Firebase 控制台-> Machine Learning,然后单击 “AutoML” 。
现在,单击添加数据集。
给数据集命名并选择第二个选项,然后单击继续。