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

Crash when using with Firebase Messaging, because of Application initilalisation. #38

Open
droidluv opened this issue Oct 4, 2019 · 4 comments

Comments

@droidluv
Copy link

droidluv commented Oct 4, 2019

Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'android.app.Application android.app.Activity.getApplication()' on a null object reference
E/AndroidRuntime( 5340): 	at com.github.adee42.keyboardvisibility.KeyboardVisibilityPlugin.registerWith(KeyboardVisibilityPlugin.java:107)
E/AndroidRuntime( 5340): 	at io.flutter.plugins.GeneratedPluginRegistrant.registerWith(GeneratedPluginRegistrant.java:38)
E/AndroidRuntime( 5340): 	at com.example.app.Application.registerWith(Application.kt:17)
E/AndroidRuntime( 5340): 	at io.flutter.plugins.firebasemessaging.FlutterFirebaseMessagingService.startBackgroundIsolate(FlutterFirebaseMessagingService.java:164)
E/AndroidRuntime( 5340): 	at io.flutter.plugins.firebasemessaging.FlutterFirebaseMessagingService.onCreate(FlutterFirebaseMessagingService.java:77)
E/AndroidRuntime( 5340): 	at android.app.ActivityThread.handleCreateService(ActivityThread.java:3953)

the crash happens in line 107 of https://github.com/adee42/flutter_keyboard_visibility/blob/master/android/src/main/java/com/github/adee42/keyboardvisibility/KeyboardVisibilityPlugin.java

at registrar.activity().getApplication().registerActivityLifecycleCallbacks(instance);
where registrar.activity() return null because registration is happening in Application class, can you have a null check set for this.

@droidluv
Copy link
Author

droidluv commented Oct 4, 2019

I just looked at the PR's, because I was thinking of making one and found somebody has already beat me to it, and that fix was forked over and is now available over here https://github.com/MisterJimson/flutter_keyboard_visibility and this is the working fine!

@jmgjmg
Copy link

jmgjmg commented Oct 29, 2019

The issue is due to the fact that the Firebase Messaging plugin is creating a headless isolate (not associated to a view or activity) which results in the call to registerWith() method with a null activity.

registrar.activity().getApplication().registerActivityLifecycleCallbacks(instance);

@g-balas
Copy link

g-balas commented Nov 19, 2019

@droidluv I can confirm that fixed it for me. It was the facebook_login plugin that messed it up.

@sgehrman
Copy link

Any plan on fixing this? Same issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants