I am currently working in an Android application that requires to have Admin and regular users. To illustrate, the admin has the ability to manage the regular users like delete , modify their contents. According to my reserch that firebase provide Admin SDK API that can be realy sutiable for this issue but according to thier documention that Admin SDK cannot be used in the Android project itself and should be placed in the server-side of the project. In addition, i was tried to add the Admin SDK debendence to my project dependences but there is conflict between the libraries . I know what i was did is wrong to add the Admin SDK to the Bulid.gradle (app) but i did not manage to figure out how i can add the Admin SDK to my project.
1 Answers
What you've found is correct. Your case seems to be suitable for using Firebase Admin SDK.
Firebase Admin SDK needs a server app, on which it will be initialized.
Here you can find a full list of the prerequisites for setting-up Firebase Android SDK.
You can set-up Firebase Functions, which will hold your server-side code. Inside those functions you can also initialize the Firebase Admin SDK.
Please refer here for more information on Firebase Functions.
Here you can find a sample Firebase application which uses the Admin SDK. The sample shows how to authenticate access to a JSON API to only allow access to data for a specific Firebase user.
Firebase Functions are built to serve as serverless code, as you develop your server-side logic, then deploy it to a managed environment on Google's cloud. Those functions can contain all the logic that you would like to have using Admin SDK.

- 377
- 4
- 14
-
First of all, Thank you for your replied, I need to know to know this dependency should be placed where. dependencies { implementation 'com.google.firebase:firebase-admin:6.6.0' } – Alex Dec 13 '18 at 11:13
-
The dependency that you mention is the Firebase Admin Java SDK - https://github.com/firebase/firebase-admin-java. If you do have a service running in Java, adding this dependency will enable access to Firebase services. Next to that, https://github.com/firebase/quickstart-android/tree/master/functions is a sample Android project, which makes use of Firebase Functions. The Firebase Functions are located in the "functions" directory. – Bilger Yahov Dec 13 '18 at 11:28
-
So, imagine it like that: You will need a server app to use Firebase Admin SDK. If you do have a Java service running somewhere, then you can use the dependency mentioned by you. If that is not the case, then the easiest way to go would be choosing for Firebase Functions. They will serve as NodeJS micro-services, which will contain all the server-side logic that's needed (including the Firebase Admin SDK usage). – Bilger Yahov Dec 13 '18 at 11:33
-
All I need to do is give the Admin user full control over the application like deleting others users or editing their data if needed – Alex Dec 13 '18 at 12:13
-
2@Alex Using the Admin SDK requires that you specify credentials that give full administrative access to your Firebase project. This is not possible in an Android app, because it would be a huge security risk. If you shipped that app to your regular users too, they could decompile the app, get those credentials, and for example delete your entire database too. For this reason you should only use the Admin SDK in a trusted environment, and then (securely) expose specific functionality to the admins in the Android app. – Frank van Puffelen Dec 13 '18 at 14:36
-
I got you, as you said the Admin SDK should be used in a trusted environment which I am using firebase database as backend services. The thing that I do not understand how I can integrate Admin SDK with a project , where I should place this library in order to get advantage of it – Alex Dec 14 '18 at 00:23
-
Imagine it like this - you have an Android app on which you make use of Firebase for BaaS provider, next to that you have an external service (Java or NodeJS, or...) on which you initialize and make use of the Firebase Admin SDK. The integration that you are talking about is just the way that this Android app will communicate with this external service. Simply remember that the external service will serve you the Firebase Admin SDK, so you will have the full admin privileges there. – Bilger Yahov Dec 14 '18 at 09:22
-
And not only that, https://firebase.google.com/docs/admin/setup here you can find a list of all the features that are available through the Admin SDK. For some of them you would not even need any integration/communication between your Android project and the external service on which the Admin SDK is running. – Bilger Yahov Dec 14 '18 at 09:26