capacitor-community / fcm

Enable Firebase Cloud Messaging for Capacitor apps
https://capacitor.ionicframework.com/docs/
MIT License
237 stars 83 forks source link

Usage with @capacitor-community/firebase-analytics causes crash on android #51

Closed timmyrosen closed 3 years ago

timmyrosen commented 3 years ago

Describe the bug Hi! Im using this plugin together with @capacitor-community/firebase-analytics (both on latest version) and when I run my app on my android device it crashes on startup.

To Reproduce Steps to reproduce the behavior:

  1. Install both @capacitor-community/fcm and @capacitor-community/firebase-analytics.
  2. Run npx cap sync

In my MainActivity.java file, I have added

import com.getcapacitor.community.fcm.FCMPlugin;
import com.getcapacitor.community.firebaseanalytics.FirebaseAnalytics;

public class MainActivity extends BridgeActivity {
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Initializes the Bridge
    this.init(savedInstanceState, new ArrayList<Class<? extends Plugin>>() {{
      // Additional plugins you've installed go here
        add(FirebaseAnalytics.class);
        add(FCMPlugin.class);
    }});
  }
}

When I run the app through android studio, it builds successfully but crashes instantly after splashscreen.

Smartphone (please complete the following information):

Additional context

I have tried reversing the order of the added plugins but to no luck.

On iOS everything works perfectly.

If I comment out the FCMPlugin.class line the app starts. If I remove the analytics line + import, the app still crashes. I have to remove the plugin completely for the app to work again.

So I can start the app using either of these plugins seperately but not together.

timmyrosen commented 3 years ago

Ok I solved it thanks to this comment https://github.com/ionic-team/capacitor/issues/2906#issuecomment-627582190