"SoLoader.init() not yet called" when integrating react-native into existing android-app

See original GitHub issue

React Native version:

System:
    OS: macOS High Sierra 10.13.6
    CPU: (4) x64 Intel(R) Core(TM) i5-2400S CPU @ 2.50GHz
    Memory: 107.27 MB / 14.00 GB
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 10.16.1 - /usr/local/bin/node
    Yarn: 1.17.3 - /usr/local/bin/yarn
    npm: 6.10.3 - /usr/local/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  SDKs:
    iOS SDK:
      Platforms: iOS 12.1, macOS 10.14, tvOS 12.1, watchOS 5.1
    Android SDK:
      API Levels: 23, 25, 26, 27, 28
      Build Tools: 23.0.1, 26.0.1, 26.0.3, 27.0.3, 28.0.3
      System Images: android-27 | Google Play Intel x86 Atom, android-28 | Google APIs Intel x86 Atom
  IDEs:
    Android Studio: 3.4 AI-183.6156.11.34.5692245
    Xcode: 10.1/10B61 - /usr/bin/xcodebuild
  npmPackages:
    react: 16.8.6 => 16.8.6
    react-native: 0.60.4 => 0.60.4
  npmGlobalPackages:
    react-native-cli: 2.0.1

Steps To Reproduce

  1. create react-native-app
  2. create android-app
  3. follow the official guide of react native to integrate react-native-app into existing android-app: https://facebook.github.io/react-native/docs/integration-with-existing-apps.html
  4. start android-app and open react-native-app

At this point, the react-native-app should open, not crashing.

I get this error-msg:

E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example.myapplication, PID: 9668
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.myapplication/com.example.myapplication.MainActivity}: java.lang.RuntimeException: SoLoader.init() not yet called
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2778)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
        at android.app.ActivityThread.-wrap11(Unknown Source:0)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:164)
        at android.app.ActivityThread.main(ActivityThread.java:6494)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
     Caused by: java.lang.RuntimeException: SoLoader.init() not yet called
        at com.facebook.soloader.SoLoader.assertInitialized(SoLoader.java:781)
        at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:505)
        at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:484)
        at com.facebook.react.ReactInstanceManagerBuilder.getDefaultJSExecutorFactory(ReactInstanceManagerBuilder.java:304)
        at com.facebook.react.ReactInstanceManagerBuilder.build(ReactInstanceManagerBuilder.java:279)
        at com.example.myapplication.MainActivity.onCreate(MainActivity.java:45)
        at android.app.Activity.performCreate(Activity.java:7009)
        at android.app.Activity.performCreate(Activity.java:7000)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2731)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856) 
        at android.app.ActivityThread.-wrap11(Unknown Source:0) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589) 
        at android.os.Handler.dispatchMessage(Handler.java:106) 
        at android.os.Looper.loop(Looper.java:164) 
        at android.app.ActivityThread.main(ActivityThread.java:6494) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807) 

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:3
  • Comments:12

github_iconTop GitHub Comments

10reactions
tbergquist-godaddycommented, Aug 9, 2019

You need to override the onCreate function and call SoLoader.init(this, /* native exopackage */ false);

See this example

8reactions
leandrosimoescommented, Sep 19, 2019

I fixed the error by adding this override to my MainApplication.java:

  @Override
  public void onCreate() {
    super.onCreate();
    SoLoader.init(this, /* native exopackage */ false);
  }
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to integrate react native code with an existing Android app?
I was tinkering with react native recently and learned a few things about setting up the dev environment and running it. This post...
Read more >
Integration with Existing Apps - React Native
The keys to integrating React Native components into your Android application are to: Set up React Native dependencies and directory structure.
Read more >
How to Integrate an Existing Android App with React Native
Firstly, create a folder named “android” and place your existing native application within that folder. Now create a 'package.json' within the ...
Read more >
Integrating react-native into existing App - Stack Overflow
we are trying to integrate react-native into our existing android application: The SDK requirements of our build.gradle are:
Read more >
How to integrate React Native components into native apps
Setting up project directories. If no native Android application has been created using Android Studio, a new application can be created.
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