awesome_notifications
awesome_notifications copied to clipboard
Crashes: Unable to start activity... ComponentName.getClassName()' on a null object reference
This crashes received into FirebaseCrashlytics when app was lunched from terminated state after tapping on notification...and after that notifications stop coming until i restart service with notifications again. This happened on different devices with android sdk >23 What could be the reason? Or could you say how to refuse launch app from terminated state when i tap on notification to avoid this case?
i use gradle-5.6.2 and i have in dependencies in pubspec audioplayers: ^0.17.4; awesome_notifications: ^0.0.5+8.....
Fatal Exception: java.lang.RuntimeException Unable to start activity ComponentInfo{app.norbu/com.ryanheise.audioservice.AudioServiceActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.content.ComponentName.getClassName()' on a null object reference android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2825) android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:2903) android.app.ActivityThread.-wrap11 (ActivityThread.java) android.app.ActivityThread$H.handleMessage (ActivityThread.java:1627) android.os.Handler.dispatchMessage (Handler.java:106) android.os.Looper.loop (Looper.java:164) android.app.ActivityThread.main (ActivityThread.java:6567) java.lang.reflect.Method.invoke (Method.java) com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:438) com.android.internal.os.ZygoteInit.main (ZygoteInit.java:857)
Caused by java.lang.NullPointerException Attempt to invoke virtual method 'java.lang.String android.content.ComponentName.getClassName()' on a null object reference arrow_right me.carda.awesome_notifications.AwesomeNotificationsPlugin.onAttachedToActivity (AwesomeNotificationsPlugin.java:224) io.flutter.embedding.engine.FlutterEngineConnectionRegistry.attachToActivityInternal (FlutterEngineConnectionRegistry.java:362) io.flutter.embedding.engine.FlutterEngineConnectionRegistry.attachToActivity (FlutterEngineConnectionRegistry.java:344) io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.onAttach (FlutterActivityAndFragmentDelegate.java:169) io.flutter.embedding.android.FlutterActivity.onCreate (FlutterActivity.java:409)
I had the same issue here recently. The error message also includes audioservice like you do (which I assume could be caused by some conflict between audioservice and awesome notification). Did you find the solution to this? Additional info: I'm using audio_service: ^0.18.2, awesome_notifications: ^0.6.19, Flutter Channel stable, 2.5.3 and Dart version 2.14.4
There is nothing to do with audio. Its the method to get the main class name. This is the only way to tell to OS who he needs to call inside your app when a notification is tapped.
For some reason some apps cannot inform the main class. But i guess this issue was fixed a way time ago. Which awesome version are you using?
There is nothing to do with audio. Its the method to get the main class name. This is the only way to tell to OS who he needs to call inside your app when a notification is tapped.
For some reason some apps cannot inform the main class. But i guess this issue was fixed a way time ago. Which awesome version are you using?
0.6.19
Can you provide us some log information or anything else that cold help us to figure out whats going on?
Can you provide us some log information or anything else that cold help us to figure out whats going on?
I only have error messages from Google Crashlytics, and the messages are exactly like the thread creater's (sorry for the format, edited from my phone):
Fatal Exception: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.pomodoro.foca/com.ryanheise.audioservice.AudioServiceActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.content.ComponentName.getClassName()' on a null object reference at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3183) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3318) at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78) at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2022) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:224) at android.app.ActivityThread.main(ActivityThread.java:7147) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:511) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:876) Caused by java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.content.ComponentName.getClassName()' on a null object reference at me.carda.awesome_notifications.AwesomeNotificationsPlugin.onAttachedToActivity(AwesomeNotificationsPlugin.java:36) at io.flutter.embedding.engine.FlutterEngineConnectionRegistry.a(FlutterEngineConnectionRegistry.java:62) at io.flutter.embedding.engine.FlutterEngineConnectionRegistry.a(FlutterEngineConnectionRegistry.java:96) at io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.a(FlutterActivityAndFragmentDelegate.java:37) at io.flutter.embedding.android.FlutterActivity.onCreate(FlutterActivity.java:15) at android.app.Activity.performCreate(Activity.java:7272) at android.app.Activity.performCreate(Activity.java:7263) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1275) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3163) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3318) at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78) at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2022) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:224) at android.app.ActivityThread.main(ActivityThread.java:7147) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:511) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:876)
The error is right here:
https://github.com/rafaelsetragni/awesome_notifications/blob/3f5c77193d2ad47fb8d49e677a1fa9a37b9dd6bb/android/src/main/java/me/carda/awesome_notifications/AwesomeNotificationsPlugin.java#L184
mainTargetClassName needs to have the main class name of your application. I dont know why your app does not have an intent with a component defined.
The error is right here:
https://github.com/rafaelsetragni/awesome_notifications/blob/3f5c77193d2ad47fb8d49e677a1fa9a37b9dd6bb/android/src/main/java/me/carda/awesome_notifications/AwesomeNotificationsPlugin.java#L184
mainTargetClassName needs to have the main class name of your application. I dont know why your app does not have an intent with a component defined.
Thanks! I'm currently having 2 activities inside AndroidManifest.xml (which is not intentional), I'm guessing that is the issue. I will test whether merging these 2 into 1 works.
I'm starting to see the issue again after reducing number of activity to 1 in AndroidManifest.xml, so issue is not related to that. Could you give me a hint on where to look for the bug?
Thanks
The point is, awesome needs to know what is your main class to point the notifications to open your app. Try to use our 0.7.0 beta, because I modified how this main class is detected.
I used your 0.7.0 beta and it is so far so good. But in the meantime, I also updated the related plugin audio_service to their latest version 0.18.4. Worth mentioning they recently closed an issue that is somewhat related to the current one: https://github.com/ryanheise/audio_service/issues/904, and the fix for that issue is contained in 0.18.4.
Ive changed how I search for the main app class. Now Im filtering by the category launcher. This way i can find the first main class that starts the app without using the getClassName method.
The solution seems great! Will this beta version be released any time soon?
Hi! Sorry for taking so long to respond to your issue on GitHub. I was focused on releasing the new 0.7.0 version of awesome_notifications
and awesome_notifications_fcm
and i didn't had time enough to do both. But now I can answer all your questions.
So now i'm asking you to recreate this topic using the new issue template. There's a lot of missing informations that i need to understand your problem, and all the instructions are already in the new issue template. Also, remember to check beforehand if your issue was posted by another user.
So I will automatically close all previous issues so far. Sorry for the inconvenience and i will be waiting for your new issue request.
Thank you so much for your support!