4

Don't mark as duplicate. This is a question for Java EE, not Android development.

I'm new to Firebase and I thought I'd give it a try to evaluate it for use in some upcoming development work, but I'm unable to even initialize Firebase.

I followed the tutorial on this page: Add Firebase to your server

I added Firebase to my pom.xml as described, ran an update on Maven to ensure it was added properly and have subclassed Application in the JAX-RS portion of my server like so:

public class HelloFirebaseApp extends Application {
    public HelloFirebaseApp(){
        FirebaseOptions options;
        try {
            options = new FirebaseOptions.Builder()
                    .setServiceAccount(new FileInputStream("Hello Firebase-124jksdjfkl32j5.json"))
                    .build();
            FirebaseApp.initializeApp(options);
            System.out.println("Firebase initialized!");
        } catch (FileNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
}

However, on deployment, I receive the following error:

Caused by: java.lang.IllegalStateException: FirebaseApp name [DEFAULT] already exists!
at com.google.firebase.internal.Preconditions.checkState(Preconditions.java:173)
at com.google.firebase.FirebaseApp.initializeApp(FirebaseApp.java:180)
at com.google.firebase.FirebaseApp.initializeApp(FirebaseApp.java:160)
at me.hello-firebase.HelloFirebaseApp.<init>(HelloFirebaseApp.java:20)

What's going on here?

KG6ZVP
  • 3,610
  • 4
  • 26
  • 45

0 Answers0