Skip to content
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

[firebase_messaging] App crashes on startup after adding onBackgroundMessage #3048

Closed
GuilhermePontes9 opened this issue Jul 28, 2020 · 5 comments · Fixed by #4012
Closed

Comments

@GuilhermePontes9
Copy link

I followed everything written in firebase_messaging readme. After adding the onBackgroundMessage handler and "Application.java" to AndroidManifest the app installs but crashes on startup. What am I doing wrong?
Thanks in advance

@GuilhermePontes9 GuilhermePontes9 changed the title App crashes on startup after adding onBackgroundMessage [firebase_messaging] App crashes on startup after adding onBackgroundMessage Jul 28, 2020
@kroikie
Copy link
Collaborator

kroikie commented Jul 28, 2020

Hi @GuilhermePontes9 could you provide the stack trace of what your error is when you app crashes?

@GuilhermePontes9
Copy link
Author

Sorry, I don't know if it's the correct way to do it but I run .\gradlew build --stacktrace and the result was this:

Task :app:compileFlutterBuildDebug
Parameter format not correct -

Task :app:stripDebugDebugSymbols UP-TO-DATE
Compatible side by side NDK version was not found.

Task :app:lint
Ran lint on variant debug: 4 issues found
Ran lint on variant release: 4 issues found
Ran lint on variant profile: 4 issues found
Wrote HTML report to file:///C:/Flutter%20Projects/sirene_virtual/build/app/reports/lint-results.html
Wrote XML report to file:///C:/Flutter%20Projects/sirene_virtual/build/app/reports/lint-results.xml

Task :audioplayers:lint
Ran lint on variant debug: 2 issues found
Ran lint on variant release: 2 issues found
Ran lint on variant profile: 2 issues found
Wrote HTML report to file:///C:/Flutter%20Projects/sirene_virtual/build/audioplayers/reports/lint-results.html
Wrote XML report to file:///C:/Flutter%20Projects/sirene_virtual/build/audioplayers/reports/lint-results.xml

Task :cloud_firestore:lint
Ran lint on variant profile: 6 issues found
Ran lint on variant release: 6 issues found
Ran lint on variant debug: 6 issues found
Wrote HTML report to file:///C:/Flutter%20Projects/sirene_virtual/build/cloud_firestore/reports/lint-results.html
Wrote XML report to file:///C:/Flutter%20Projects/sirene_virtual/build/cloud_firestore/reports/lint-results.xml

Task :firebase_auth:lint
Ran lint on variant debug: 4 issues found
Ran lint on variant release: 4 issues found
Ran lint on variant profile: 4 issues found
Wrote HTML report to file:///C:/Flutter%20Projects/sirene_virtual/build/firebase_auth/reports/lint-results.html
Wrote XML report to file:///C:/Flutter%20Projects/sirene_virtual/build/firebase_auth/reports/lint-results.xml

Task :firebase_core:lint
Ran lint on variant profile: 2 issues found
Ran lint on variant debug: 2 issues found
Ran lint on variant release: 2 issues found
Wrote HTML report to file:///C:/Flutter%20Projects/sirene_virtual/build/firebase_core/reports/lint-results.html
Wrote XML report to file:///C:/Flutter%20Projects/sirene_virtual/build/firebase_core/reports/lint-results.xml

Task :firebase_core_web:lint
Ran lint on variant debug: 1 issues found
Ran lint on variant release: 1 issues found
Ran lint on variant profile: 1 issues found
Wrote HTML report to file:///C:/Flutter%20Projects/sirene_virtual/build/firebase_core_web/reports/lint-results.html
Wrote XML report to file:///C:/Flutter%20Projects/sirene_virtual/build/firebase_core_web/reports/lint-results.xml

Task :firebase_database:lint
Ran lint on variant release: 3 issues found
Ran lint on variant debug: 3 issues found
Ran lint on variant profile: 3 issues found
Wrote HTML report to file:///C:/Flutter%20Projects/sirene_virtual/build/firebase_database/reports/lint-results.html
Wrote XML report to file:///C:/Flutter%20Projects/sirene_virtual/build/firebase_database/reports/lint-results.xml

Task :firebase_messaging:lint
Ran lint on variant release: 5 issues found
Ran lint on variant profile: 5 issues found
Ran lint on variant debug: 5 issues found
Wrote HTML report to file:///C:/Flutter%20Projects/sirene_virtual/build/firebase_messaging/reports/lint-results.html
Wrote XML report to file:///C:/Flutter%20Projects/sirene_virtual/build/firebase_messaging/reports/lint-results.xml

Task :path_provider:lint
Ran lint on variant profile: 1 issues found
Ran lint on variant debug: 1 issues found
Ran lint on variant release: 1 issues found
Wrote HTML report to file:///C:/Flutter%20Projects/sirene_virtual/build/path_provider/reports/lint-results.html
Wrote XML report to file:///C:/Flutter%20Projects/sirene_virtual/build/path_provider/reports/lint-results.xml

BUILD SUCCESSFUL in 22s
792 actionable tasks: 28 executed, 764 up-to-date

@kroikie
Copy link
Collaborator

kroikie commented Jul 28, 2020

@GuilhermePontes9 I should have been clearer. I was hoping to see the stack trace (hopefully containing some errors) you get when the app crashes.

@GuilhermePontes9
Copy link
Author

Sorry for my misunderstanding, I'm still in the process of learning all this!
This is the stacktrace i get when the app crashes:

java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{guilhermepontes.sirene_virtual/guilhermepontes.sirene_virtual.Application}: java.lang.ClassCastException: guilhermepontes.sirene_virtual.Application cannot be cast to android.app.Activity
at android.app.ActivityThread.performLaunchActivity(Unknown Source:645)
at android.app.ActivityThread.handleLaunchActivity(Unknown Source:36)
at android.app.servertransaction.LaunchActivityItem.execute(Unknown Source:57)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(Unknown Source:99)
at android.app.servertransaction.TransactionExecutor.execute(Unknown Source:34)
at android.app.ActivityThread$H.handleMessage(Unknown Source:36)
at android.os.Handler.dispatchMessage(Unknown Source:21)
at android.os.Looper.loop(Unknown Source:207)
at android.app.ActivityThread.main(Unknown Source:107)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(Unknown Source:11)
at com.android.internal.os.ZygoteInit.main(Unknown Source:274)
Caused by: java.lang.ClassCastException: guilhermepontes.sirene_virtual.Application cannot be cast to android.app.Activity
at android.app.AppComponentFactory.instantiateActivity(Unknown Source:8)
at androidx.core.app.CoreComponentFactory.instantiateActivity(CoreComponentFactory.java:41)
at android.app.Instrumentation.newActivity(Unknown Source:22)
at android.app.ActivityThread.performLaunchActivity(Unknown Source:87)
... 11 more

@GuilhermePontes9
Copy link
Author

I looked again at the instructions and realised that I added .Application in the activity tag, not on the application tag in the AndroidManifest. You can delete the issue, my bad. Thank you for your time!

@firebase firebase locked and limited conversation to collaborators Aug 29, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants