capacitor-community / fcm

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

No virtual method subscribeToTopic #49

Closed tobias47n9e closed 4 years ago

tobias47n9e commented 4 years ago

Describe the bug After installing the plugin (following the instructions) and building it successfully I get an error during runtime on Android 10. Is this caused by a plugin conflict or a version mismatch? Perhaps something is missing from the installation instructions? I couldn't find an obvious plugin conflict or version mismatch.

Desktop (please complete the following information):

Smartphone (please complete the following information):

Additional context

E/Capacitor: Serious error executing plugin java.lang.reflect.InvocationTargetException at java.lang.reflect.Method.invoke(Native Method) at com.getcapacitor.PluginHandle.invoke(PluginHandle.java:99) at com.getcapacitor.Bridge$1.run(Bridge.java:521) at android.os.Handler.handleCallback(Handler.java:883) at android.os.Handler.dispatchMessage(Handler.java:100) at android.os.Looper.loop(Looper.java:237) at android.os.HandlerThread.run(HandlerThread.java:67) Caused by: java.lang.NoSuchMethodError: No virtual method subscribeToTopic(Ljava/lang/String;)Lcom/google/android/gms/tasks/Task; in class Lcom/google/firebase/messaging/FirebaseMessaging; or its super classes (declaration of 'com.google.firebase.messaging.FirebaseMessaging' appears in /data/app/app.apk) at com.getcapacitor.community.fcm.FCMPlugin.subscribeTo(FCMPlugin.java:28) at java.lang.reflect.Method.invoke(Native Method)  at com.getcapacitor.PluginHandle.invoke(PluginHandle.java:99)  at com.getcapacitor.Bridge$1.run(Bridge.java:521)  at android.os.Handler.handleCallback(Handler.java:883)  at android.os.Handler.dispatchMessage(Handler.java:100)  at android.os.Looper.loop(Looper.java:237)  at android.os.HandlerThread.run(HandlerThread.java:67) 

askilondz commented 4 years ago

I received this error after installing the capacitor-community/firebase-analytics plugin.

askilondz commented 4 years ago

I was able to fix the issue thanks to this thread comment: https://github.com/ionic-team/capacitor/issues/2906#issuecomment-627582190

*Note: You have to create the android/variables.gradle file as explained in the Capacitor upgrade guide for capacitor version 2.0 which he links to in that comment.