0

I know it's possible to access Firebase from GCP cloud functions, but Java is not on the list of supported Languages.

https://firebase.google.com/docs/functions

I also know that it's in principle possible to write HTTP cloud functions in Java:

https://cloud.google.com/functions/docs/create-deploy-http-java

And lastly, I know that there is Android API (Java-based) for Firebase.

What I would like to do is to access data in the Firebase database from a Cloud Function written in Java. Is this possible at all, given the three facts listed above?

Can I, for instance, import Android API classes into my Java Cloud function, and hope that they will work? Sorry, I am Java back end and Swift developer, never developed for Android.

X.Mitry
  • 15
  • 4
  • 1
    Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. – Community Dec 24 '22 at 18:15

1 Answers1

0

Google Cloud Functions in general supports writing the server-side code in many languages, such as Java. See this quickstart tutorial on creating and deploying a HTTP Cloud Function by using Java. You can call this function from any platform that can make HTTP calls.

Cloud Functions for Firebase is a friendly wrapper around Google Cloud Functions. It only supports writing server-side code than runs on Node.js, so in JavaScript or TypeScript. The client-side code that calls these functions can exist in many more languages, including Java.


So if you want to write your Cloud Functions server-side code in Java, you'll have to use Google Cloud Functions directly, and won't be using the Firebase wrapper. That is not a problem, merely a choice.

Also see my answer to: What is the difference between Cloud Functions and Firebase Functions?

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
  • That's fine, just please tell me (if you know) how I programmatically access data in FireBase database from a GCP Cloud Function written in Java. This is the main sticking point for me. I do understand it's not a problem, no one is going to sue me for that. Just how to do it? That's the problem. – X.Mitry Dec 24 '22 at 23:56
  • Yeah, that should be possible, for example by using the Firebase Admin SDK as shown here: https://firebase.google.com/docs/admin/setup – Frank van Puffelen Dec 25 '22 at 04:52
  • Thank you, your last answer given in a comment contained a useful hint. I eventually figured out how to proceed with the Admin SDK. – X.Mitry Jan 17 '23 at 09:14