-
Notifications
You must be signed in to change notification settings - Fork 4k
🐛 [firebase_messaging] FCM Integration App Crashed on ClassCastException #3881
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I had same issue and found out that if I omit steps 2, 3 and 4 from Official Guidelines, everything works as expected. I think this is because plugin (or flutter) generates all necessary code in android/app/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java After installing firebase messaging, next code appeared inside registerWith function: |
@Svet-00 , are background messaging working in your app if you omit step 2,3,4 ? |
Hi @Scienticious Application
MainActviity
There are a bunch of issues for kotlon example in messaging #2311 #3411 |
Bug report
I am trying to implement Firebase push notifications in background & I am following the Official Guidelines
When I run the code error has been showing and application is crashing
A clear and concise description of what the bug is.
I have pasted the background messaging code in application file in kotlin
Crash Log
/AndroidRuntime(31418): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.firebase_push_notification_my/com.example.firebase_push_notification_my.Application}: java.lang.ClassCastException: com.example.firebase_push_notification_my.Application cannot be cast to android.app.Activity E/AndroidRuntime(31418): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2874) E/AndroidRuntime(31418): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3079) E/AndroidRuntime(31418): at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78) E/AndroidRuntime(31418): at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108) E/AndroidRuntime(31418): at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68) E/AndroidRuntime(31418): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1836) E/AndroidRuntime(31418): at android.os.Handler.dispatchMessage(Handler.java:106) E/AndroidRuntime(31418): at android.os.Looper.loop(Looper.java:193) E/AndroidRuntime(31418): at android.app.ActivityThread.main(ActivityThread.java:6702) E/AndroidRuntime(31418): at java.lang.reflect.Method.invoke(Native Method) E/AndroidRuntime(31418): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) E/AndroidRuntime(31418): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:911) E/AndroidRuntime(31418): Caused by: java.lang.ClassCastException: com.example.firebase_push_notification_my.Application cannot be cast to android.app.Activity E/AndroidRuntime(31418): at android.app.AppComponentFactory.instantiateActivity(AppComponentFactory.java:69) E/AndroidRuntime(31418): at androidx.core.app.CoreComponentFactory.instantiateActivity(CoreComponentFactory.java:41) E/AndroidRuntime(31418): at android.app.Instrumentation.newActivity(Instrumentation.java:1215) E/AndroidRuntime(31418): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2862)
Steps to reproduce
Run the App, and it will crash
Expected behavior
App has to been run and show the notification when notification come
Additional context
The Android side code must be provided in Kotlin instead of Java
Flutter doctor
Run
flutter doctor
and paste the output below:Click To Expand
Flutter dependencies
Run
flutter pub deps -- --style=compact
and paste the output below:Click To Expand
The text was updated successfully, but these errors were encountered: