Firebase Admin Sdk for Android, Methods Not Found

Firebase Admin SDK for Android, methods not found

You can't use the Firebase Admin SDK in an Android app alongside the Firebase Android client libraries. The SDKs both provide classes with the exact same package and class name, so it wouldn't possibly be able to use them both at the same time (how would the compiler know which one you intend to build into your app?).

As an example, take a look at the javadoc for FirebaseOptions Builder in the Android client library:

com.google.firebase.FirebaseOptions.Builder

Now look at the same class from the java Admin SDK (note the URL is different):

com.google.firebase.FirebaseOptions.Builder

You can see for yourself that they're different things, even though they have the same name. Your compiler is therefore looking at the Android SDK definition and not the admin SDK definition.

As Frank said, you probably don't want to use the Admin library within your Android app. If you want to use the admin SDK, use it from a server you control, and have your Android app communicate with that if needed.

Add Firebase auth and Firebase admin in same Android Project

The Firebase Admin SDK is not intended for use in Android apps. It's for backend code running in a controlled server or desktop that you fully control. Please don't try work around this - instead your Android app should be invoking a backend that uses the Admin SDK to perform the work you need. It would be a fairly massive security hole for an app to have the Admin SDK and a service account bundled into it, as that leaves your project open to direct, easy abuse by anyone who can download your app and get the service account credentials.

How to solve Firebase Admin SDK dependencies incompatibility?

Let me ask you, why do you need firebase-admin? What are you trying to acomplish?

You should not add firebase-admin to your android app, as this lib is meant to be used only on trusted sources (that is, on code that runs securely behind a server). If you added firebase-admin to your app, you would be giving admin privileges for any user using the app, and this would be a security liability for your application.

Check this answer for more information.

Firebase admin sdk with java doesn't connect

The following code worked for me:

try {
FirebaseOptions options = new FirebaseOptions.Builder()
.setCredentials(GoogleCredentials
.fromStream(new ClassPathResource("/firebase-authentication.json").getInputStream()))
.build();

if (FirebaseApp.getApps().isEmpty()) {
FirebaseApp.initializeApp(options);
}

} catch (IOException e) {
e.printStackTrace();
}

The "/firebase-authentication.json" is in the resources folder.



Related Topics



Leave a reply



Submit