question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Crash with ExpoKit

See original GitHub issue

Hi ! I encountered so much problems integrating this library with expokit, but now, i’m really close of it ! I don’t have any problems with iOS but Android drives me mad.

When I receive an notification on Android, it’ll instantly crash with this error java.lang.NullPointerException: Attempt to invoke virtual method 'com.facebook.react.ReactInstanceManager com.facebook.react.ReactNativeHost.getReactInstanceManager()' on a null object reference

because of this line ReactInstanceManager mReactInstanceManager = ((ReactApplication) getApplication()).getReactNativeHost().getReactInstanceManager();

My MainApplication class is like this:

package com.productinuse.preprod;

import android.support.multidex.MultiDexApplication;

import com.facebook.react.ReactPackage;

import java.util.Arrays;
import java.util.List;

import com.evollu.react.fcm.FIRMessagingPackage;

public class MainApplication extends MultiDexApplication {
  public List<ReactPackage> getPackages() {
    return Arrays.<ReactPackage>asList(
        // Add your own packages here!
        new FIRMessagingPackage()
    );
  }
}

It doesn’t implement ReactApplication because of the ExpoKit implementation.

I already see this and this without any solutions

react-native-fcm: 7.5.1 expokit: sdk 19 @evollu I mention you because I’m really desperate aha 😉

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:15 (3 by maintainers)

github_iconTop GitHub Comments

5reactions
amanforindiacommented, Nov 19, 2017

For others trying to configure it, I got it to work by changing MessagingService:

Handler handler = new Handler(Looper.getMainLooper());
        handler.post(new Runnable() {
            public void run() {
                // Construct and load our normal React JS code bundle
                ReactInstanceManager mReactInstanceManager = ((ReactApplication) getApplication()).getReactNativeHost().getReactInstanceManager();

last line changed to :

ReactInstanceManager mReactInstanceManager = ((MainActivity)Exponent.getInstance().getCurrentActivity()).getReactInstanceManager();

Where I added a method in MainActivity (which extends ExponentActivity) like:

  public ReactInstanceManager getReactInstanceManager() {
    return (ReactInstanceManager) mReactInstanceManager.get();
  }

Not sure if this can be be done with PR or not.

1reaction
anish000kumarcommented, Feb 25, 2018

@amanforindia Can you please share the imports used in your snippet? Currently, it highlights (MainActivity)Exponent in red for me, saying unable to resolve symbol

Read more comments on GitHub >

github_iconTop Results From Across the Web

iOS: Expokit 36.0 App Build Crashes Upon Startup · Issue #6775
The app to startup as it does in development. Actual Behavior. The app crashes immediately after displaying the splash screen. Crash Report. I ......
Read more >
Android production build high crash rate - #22 by amorimluc
SDK 35, ejected with ExpoKit. Getting high crash rate on Android with: java.lang.RuntimeException: at host.exp.exponent.experience.
Read more >
React-native app with expokit crash on android release build
Application is created with expo and detached to expokit. I'm using expoKit version 27. It crashes only on first install, after refreshing ...
Read more >
Expokit Android app crashes after load : r/exponent - Reddit
Expokit Android app crashes after load. So I have a detached expo app. I have an Android app on my device which successfully...
Read more >
Android crash when I use react-native-webrtc in expo eject to ...
Coding example for the question Android crash when I use react-native-webrtc in expo eject to expokit project-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