Search code examples
androidsdkfirebase-analyticsandroid-studio-3.5

Need Single Firebase Analytics for Android SDK and Android Application in android


I have developed a SDK and integrated Firebase analytics in it. And also i have an android application integrated with another firebase analytics. Now I want to integrate this SDK in android application and want to track both SDK and Application's analytics with single firebase account. Is there any solution to achieve it?


Solution

  • It's Ok.

    You can multiple firebase apps in one application. One for the sdk and one for the app.

    First, you create 2 separate apps first on the firebase project. Then, the trick here is you create multiple FirebaseOption and init the FirebaseApp with as much options as you want.

      FirebaseOptions options1 =
          new FirebaseOptions.Builder(firebaseOptions)
              .setProjectId("mock-project-id-1")
              .build();
      FirebaseApp.initializeApp(options1, "testVerifyIdTokenWithExplicitProjectId");
    
        FirebaseOptions options2 =
          new FirebaseOptions.Builder(firebaseOptions)
              .setProjectId("mock-project-id-2")
              .build();
      FirebaseApp.initializeApp(options2, "testVerifyIdTokenWithExplicitProjectId");
    

    https://firebase.googleblog.com/2016/12/working-with-multiple-firebase-projects-in-an-android-app.html