简体   繁体   中英

How to use the Cloud Functions in order to use Firebase Cloud vision

I just recently upgraded my Firebase account to blaze to try out the Machine Learning features of Firebase. I am following closely this guide by google: https://firebase.google.com/docs/ml/android/recognize-text (Reading this one is going to be essential as I'm going to refer to it continuously)

I've followed every single step until the Second point, which is giving me problems:

  1. Invoke the callable function to recognize text.

To recognize text in an image, invoke the callable function, passing a JSON Cloud Vision request.

First, initialize an instance of Cloud Functions:

 private lateinit var functions: FirebaseFunctions //... functions = Firebase.functions

If I'm getting this right the "functions" of type FirebaseFunction should be the functions he told me to deploy beforehand by command line. But I don't understand where these functions should be put, and as such Android Studio isn't recognizing the reference "Firebase.functions" as you can see in this image.

在此处输入图像描述

The deployment of the functions was successful, but anywhere in this guide I found where should I put those functions... What am I getting wrong? I'm still an extreme noob about Firebase, so I beg for your patience.

You're using code that uses the Kotlin extensions for Cloud Functions for Firebase. So be sure to include the Kotlin Extensions library (typically referred to as ktx ) in your build.gradle as shown in the documentation on setting up your Android app :

dependencies {
    // Import the BoM for the Firebase platform
    implementation platform('com.google.firebase:firebase-bom:28.4.0')

    // Declare the dependency for the Cloud Functions library
    // When using the BoM, you don't specify versions in Firebase library dependencies
    implementation 'com.google.firebase:firebase-functions-ktx' // 👈 don't forget
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM