George Finn George Finn - 4 months ago 62
Android Question

Requiring unknown module "react-native-safari-view" in Release mode

I have a React Native project and it runs successfully on both simulators and devices for iOS.

However, for Android, it runs successfully on simulators without any problems, but when run on devices as a Release build, it gives me this error:

Requiring unknown module "react-native-safari-view".


I tried
npm cache clean
and
npm install
several times, but it does not work.

The module exists in
node_modules
folder and it is also under
dependencies
in
package.json
.

What could be the cause of this? Why does it happen only in Release builds?

Update: If this is difficult to fix, is it possible to generate a signed apk with the js bundle included in dev mode?

Answer

It is because react-native-safari-view module is not designed for Android.

Check this out: (inside index.android.js file in GitHub)

var SafariViewManager = {
  test: function() {
    warning('Not yet implemented for Android.');
  },
  isAvailable: function() {
    ...
  }
};

Maybe you are initiating a SafariViewManager object and calling other functions like show() in index.ios.js without checking it isAvailable()?