facebook/react-native

wtf `java.lang.RuntimeException:SoLoader.init() not yet called`

sopaco opened this issue · 10 comments

What's wrong?

java.lang.ExceptionInInitializerError:
2 com.facebook.react.bridge.NativeMap.<clinit>(NativeMap.java:22)
3 ......
4 Caused by:
5 java.lang.RuntimeException:SoLoader.init() not yet called
6 com.facebook.soloader.SoLoader.assertInitialized(SoLoader.java:335)
7 com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:238)
8 com.facebook.react.bridge.ReactBridge.staticInit(ReactBridge.java:24)
9 com.facebook.react.bridge.ReactBridge.<clinit>(ReactBridge.java:20)
10 com.facebook.react.bridge.NativeMap.<clinit>(NativeMap.java:22)
11 com.facebook.react.bridge.Arguments.createMap(Arguments.java:29)

This also happened to me. My specific case:
I am trying out the HeadlessJsTaskService. If I attempt to spin up the task (service) while the react native app is not running, it will attempt to load two libraries but the SoLoader is not yet initialized.

From ReactBridge.java:

public static void staticInit() {
    SoLoader.loadLibrary(REACT_NATIVE_LIB);
    SoLoader.loadLibrary(XREACT_NATIVE_LIB);
  }

Not sure if this is the same problem you are having, but it seems to be that the React Native Bridge is not making sure the SoLoader is initialized before initializing itself. Again this is only happening for me when the React Native App is not running, however my understanding of the HeadlessJsTaskService is that it is allowed to run when your app is not.

I think this is the same problem they are having in issue #10352

Hey, thanks for reporting this issue.

Can you please add all the info specified in the template? This is necessary for people to be able to understand and reproduce the issue being reported.

This problem showed up when calling :

WritableMap map = Arguments.fromBundle(bundle);

The Arguments is from com.facebook.react.bridge.
The app was killed before calling this method, and awakened by click a notification.

So is there any solution here to avoid this error while React-Native is not ready yet? Should we hold up ongoing process until RN did initialized? But how can we do that?

One thing that fixes this for me on 0.38.1 is after initializing ReactNativeHost, immediately calling getReactInstanceManager().

@ewindso Could you give us more detail please?

@ewindso, any updates? it will be highly appreciated :)

Closing due to lack of follow up from the original author.

I was getting same issue (checked in logcat). I found there was no function in MainApplication.java as SoLoader.init(this, /* native exopackage */ false); . At the time of adding facebook sdk , I had removed this. Added it back and working fine in my case.

  public void onCreate() {
    super.onCreate();
    FacebookSdk.sdkInitialize(getApplicationContext());
    // If you want to use AppEventsLogger to log events.
    AppEventsLogger.activateApp(this);

    SoLoader.init(this, /* native exopackage */ false);
  }```

@sachinwak have you found the solution of your problem?