0

I want to add new users in a activity and then add to Firebase authentication.

my code is this:

oncreate method

mAuth1 = FirebaseAuth.getInstance();

FirebaseOptions firebaseOptions = new FirebaseOptions.Builder()
            .setDatabaseUrl("https://gogamification-a47c8.firebaseio.com/")
            .setApiKey("AIzaSyAvwdm930yvxdpcGUNTvIqHDK7WlQZuqOY")
            .setApplicationId("1:635406806183:android:dd81a8e31701747e").build();

FirebaseApp myApp = FirebaseApp.initializeApp(getApplicationContext(),firebaseOptions,
            "GoGamification2");

mAuth2 = FirebaseAuth.getInstance(myApp);

add user method

mAuth2.createUserWithEmailAndPassword(email.toString(), pass);

I add users to my firebase database very well. When i click the button add user it adds the user in my firebase database and it goes back to my UsersActivity where i have a list of users and a button to add more. ut then when i click the button to add a new user it gives me this error:

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.tsiw.gogamification/com.tsiw.gogamification.AdicionarMembrosActitity}: java.lang.IllegalStateException: FirebaseApp name GoGamification2 already exists!

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
  • Your activity is trying to reinitialize a `FirebaseApp` that has already been initialized. You should like move this code into a [content provider](https://developer.android.com/guide/topics/providers/content-provider-creating.html) or into an [app instance](https://developer.android.com/reference/android/app/Application.html). Also see my comment here: https://stackoverflow.com/questions/37634767/how-to-connect-to-more-than-one-firebase-database-from-an-android-app#comment62899818_37643374 – Frank van Puffelen May 30 '17 at 14:25
  • well..I think you are using very old version of Firebase check the new docs again – MrCurious May 31 '17 at 06:17

0 Answers0