HeadlessTasks not working on Android devices, Module AppRegistry is not a registered callable module

See original GitHub issue

I am using firebase to push real time config update to my app, receiving real time updates work when the app is in foreground. When the app is in the background i am having 2 errors. We use a detached EXPO application. Expo SDK version : 33

  1. I am getting a App crash with the following error
java.lang.RuntimeException: Unable to start service io.invertase.firebase.messaging.RNFirebaseBackgroundMessagingService@9e4124f with Intent { cmp=com.qliro.qliro.dev/io.invertase.firebase.messaging.RNFirebaseBackgroundMessagingService (has extras) }: java.lang.ClassCastException: host.exp.exponent.MainApplication cannot be cast to com.facebook.react.ReactApplication
        at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3686)
        at android.app.ActivityThread.access$1600(ActivityThread.java:199)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1681)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:193)
        at android.app.ActivityThread.main(ActivityThread.java:6669)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
     Caused by: java.lang.ClassCastException: host.exp.exponent.MainApplication cannot be cast to com.facebook.react.ReactApplication
        at com.facebook.react.HeadlessJsTaskService.getReactNativeHost(HeadlessJsTaskService.java:171)
        at com.facebook.react.HeadlessJsTaskService.startTask(HeadlessJsTaskService.java:100)
        at com.facebook.react.HeadlessJsTaskService.onStartCommand(HeadlessJsTaskService.java:52)
        at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3667)
        at android.app.ActivityThread.access$1600(ActivityThread.java:199) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1681) 
        at android.os.Handler.dispatchMessage(Handler.java:106) 
        at android.os.Looper.loop(Looper.java:193) 
        at android.app.ActivityThread.main(ActivityThread.java:6669) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858) 

if i implement the public class MainApplication extends ExpoApplication implements AppLoaderPackagesProviderInterface<ReactPackage>,ReactApplication ReactApplication I get the issue 2

2019-07-25 12:10:27.796 7355-7537/com.qliro.qliro.dev W/ReactNativeJS: The "UMNativeModulesProxy" native module is not exported through NativeModules; verify that @unimodules/react-native-adapter's native code is linked properly
2019-07-25 12:10:27.869 7355-7537/com.qliro.qliro.dev W/ReactNativeJS: No native ExponentConstants module found, are you sure the expo-constants's module is linked properly?
2019-07-25 12:10:27.890 7355-7537/com.qliro.qliro.dev E/ReactNativeJS: The Expo SDK requires Expo to run. It appears the native Expo modules are unavailable and this code is not running on Expo. Visit https://docs.expo.io to learn more about developing an Expo project.
2019-07-25 12:10:27.898 7355-7537/com.qliro.qliro.dev E/ReactNativeJS: Module AppRegistry is not a registered callable module (calling startHeadlessTask)```

Android Manifest : 

<service android:name="io.invertase.firebase.messaging.RNFirebaseMessagingService"> <intent-filter> <action android:name="com.google.firebase.MESSAGING_EVENT" /> </intent-filter> </service> <service android:name="io.invertase.firebase.messaging.RNFirebaseInstanceIdService"> <intent-filter> <action android:name="com.google.firebase.INSTANCE_ID_EVENT" /> </intent-filter> </service> <service android:name="io.invertase.firebase.messaging.RNFirebaseBackgroundMessagingService"/>


JS File 
// Current main application
AppRegistry.registerComponent('App Name', () => App);
// New task registration
AppRegistry.registerHeadlessTask('RNFirebaseBackgroundMessage', () => bgMessaging);


I tried creating a native headless service and still had the same error.  Is there a way to get HeadlessTasks working with expo kit detached  ? 

Thank you for your help. 

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:10 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
niv-breezcommented, Sep 25, 2019

Thank you for sharing the code!

0reactions
stale[bot]commented, Mar 5, 2020

This issue has been automatically closed since there has not been any recent activity after it was marked as stale. Please open a new issue for any related bugs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

HeadlessTasks not working on Android devices, Module ... - GitHub
HeadlessTasks not working on Android devices, Module AppRegistry is not a registered callable module # ... () => App); // New task registration...
Read more >
React-Native: Module AppRegistry is not a registered callable ...
i just upgraded to react-native 0.18.1 today tough having some peer dependencies issues with 0.19.0-rc pre-release version. Back to your question, ...
Read more >
React-Native: Module AppRegistry is not a registered callable ...
... Module AppRegistry is not a registered callable module [ Beautify Your Computer : https://www.hows.tech/p/recommended.html ] Android...
Read more >
module appregistry is not a registered callable ... - You.com
I am using React native and am getting the same error again and again. Tried everything like closing all running node programs, clearing...
Read more >
Module AppRegistry is not a registered callable module-React ...
Coding example for the question Module AppRegistry is not a registered callable module-React Native.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found