0
votes

I'm Currently working on Firebase SDK in java. So to add the SDK I added compile 'com.google.firebase:firebase-admin:5.9.0' to dependecies in build.gradle and when I start writing my API it shows error on FirebaseOptions.

Error is on FirebaseOptions options = new FirebaseOptions.Builder().setCredentials(GoogleCredentials.fromStream(serviceAccount)).build();

Using this as a reference https://firebase.google.com/docs/admin/setup

Don't know what exactly the problem is?

2

2 Answers

1
votes

Ran into the same issue, I figure its some kind of library dependency error - I reverted back to the old deprecated code and it works (for now)

(I'm using the Firebase Admin SDK with Spring Boot)

@Bean
public FirebaseAuth firebaseAuth() {
    InputStream in =
            getClass().getResourceAsStream("/firebase-adminsdk.json");

    FirebaseOptions options = new FirebaseOptions.Builder()
            .setCredential(FirebaseCredentials.fromCertificate(in))
            .setDatabaseUrl("<db-url-here>")
            .build();

    FirebaseApp.initializeApp(options);

    return FirebaseAuth.getInstance();
}
0
votes

Definitely a dependency issue. For me, I just needed to upgrade my firebase admin dependency from

implementation 'com.google.firebase:firebase-admin:6.2.0'

to

implementation 'com.google.firebase:firebase-admin:6.5.0'