Monday, 2 September 2019

Firebase Google Analytics with custom FirebaseOptions initilaize method

I have to add simple Firebase Google Analytics for my android application.

I need to select my app's Firebase project at runtime.

"It's very rare, but sometimes an app must be able to select its Firebase project at runtime. This means your app can't use the automatic init provided by the FirebaseInitProvider that's merged into your app. In that case, the solution has two tasks."

Link for reference : https://firebase.googleblog.com/2017/03/take-control-of-your-firebase-init-on.html

So, In my case I have done as below :

  1. Created an Application class :

    public class MyApplicationClass extends Application {
            @Override
            public void onCreate() {
                super.onCreate();
                FirebaseOptions.Builder builder = new FirebaseOptions.Builder().setApplicationId("1:5478125639014:android:054aa87g102b94aa5").setApiKey("ABcdXyzpQrst_8tlItnC5rcbgxkK_PqrstGWsTKo");
                FirebaseApp.initializeApp(this, builder.build());
    }
    
    
  2. Added required manifest Internet permissions.

  3. Added dependencies :

    implementation 'com.google.firebase:firebase-analytics:17.1.0'

Issue is I can't see any analytics data there and Application is not getting connected in Google Analytic's final step.

What might be issue or something pending there ?



from Firebase Google Analytics with custom FirebaseOptions initilaize method

No comments:

Post a Comment