expo / config-plugins

Out-of-tree Expo config plugins for packages that haven't adopted the config plugin system yet.
428 stars 91 forks source link

Couldn't find DSO to load: libhermes.so #122

Open top-kat opened 1 year ago

top-kat commented 1 year ago

Summary

Hi,

I have spend 2 days tried to fix this error but it keeps appearing whatever I try.

Here is a related StackOverflow question

It works when I remove ffmpeg plugin and packages from npm modules, and it works on iOS

I have tried

I am out of solutions now

Config Plugin

@config-plugins/ffmpeg-kit-react-native

What platform(s) does this occur on?

Android

SDK Version

~46.0.13

Reproducible demo

https://github.com/top-kat/expo-ffmpeg-kit-example

Run

jpalumickas commented 1 year ago

We have the same problem, we also have have ffmpeg installed.

jpalumickas commented 1 year ago

I found a way how to solve this issue. So basically this ffmpeg plugin changes android minSdkVersion to version 24 and it causes this error. What we do, is we use lts version for android, which requires minSdkVersion 16 and we patched this config plugin to not update minSdkVersion. Here is the patch-package patch:

diff --git a/node_modules/@config-plugins/ffmpeg-kit-react-native/build/withAndroidFFMPEGPackage.js b/node_modules/@config-plugins/ffmpeg-kit-react-native/build/withAndroidFFMPEGPackage.js
index eeba457..4274e7c 100644
--- a/node_modules/@config-plugins/ffmpeg-kit-react-native/build/withAndroidFFMPEGPackage.js
+++ b/node_modules/@config-plugins/ffmpeg-kit-react-native/build/withAndroidFFMPEGPackage.js
@@ -27,6 +27,27 @@ function addPackageName(src, packageName) {
         comment: "//",
     }).contents;
 }
+const withAndroidSharedLibraryHandled = (config) => {
+    return config_plugins_1.withAppBuildGradle(config, (config) => {
+        if (config.modResults.language === "groovy") {
+            const fileStr = config.modResults.contents;
+            // const searchForExistingPackagingOptions = new RegExp(`(packagingOptions \{ )`)
+            // if no existing packagingOptions let's put it at the top of the android build.gradle
+            const regex = new RegExp('(android \{)')
+            config.modResults.contents = fileStr.replace(regex, `$1\n\tpackagingOptions {
+        pickFirst 'lib/x86/libc++_shared.so'
+        pickFirst 'lib/x86_64/libc++_shared.so'
+        pickFirst 'lib/armeabi-v7a/libc++_shared.so'
+        pickFirst 'lib/arm64-v8a/libc++_shared.so'
+    }\n` );
+        }
+        else {
+            throw new Error("Cannot add camera maven gradle because the build.gradle is not groovy");
+        }
+        return config;
+    });
+}
+exports.withAndroidSharedLibraryHandled = withAndroidSharedLibraryHandled;
 exports.addPackageName = addPackageName;
 // Fork of config-plugins mergeContents, but appends the contents to the end of the file.
 function appendContents({ src, newSrc, tag, comment, }) {
diff --git a/node_modules/@config-plugins/ffmpeg-kit-react-native/build/withFFMPEG.js b/node_modules/@config-plugins/ffmpeg-kit-react-native/build/withFFMPEG.js
index fa33704..69c6e46 100644
--- a/node_modules/@config-plugins/ffmpeg-kit-react-native/build/withFFMPEG.js
+++ b/node_modules/@config-plugins/ffmpeg-kit-react-native/build/withFFMPEG.js
@@ -29,11 +29,12 @@ const withFFMPEG = (config, _props) => {
             {
                 android: {
                     // https://github.com/expo/expo/blob/sdk-46/templates/expo-template-bare-minimum/android/build.gradle#L8
-                    minSdkVersion: 24,
+                    minSdkVersion: 21,
                 },
             },
         ],
         [withAndroidFFMPEGPackage_1.withAndroidFFMPEGPackage, androidPackage],
+        withAndroidFFMPEGPackage_1.withAndroidSharedLibraryHandled,
     ]);
 };
 module.exports = (0, config_plugins_1.createRunOncePlugin)(withFFMPEG, pkg.name, pkg.version);

and this is our plugin config

      [
        '@config-plugins/ffmpeg-kit-react-native',
        {
          package: 'video-lts',
          ios: {
            package: 'video',
          },
        },
      ],
codefist commented 1 year ago

Getting this same error, trying to use the plugin: https://github.com/react-native-webrtc/react-native-webrtc

I'm on versions: @config-plugins/react-native-webrtc": "^5.0.0", "expo": "~47.0.9", "react-native-webrtc": "^106.0.1"

Here's a screenshot from my android emulator:

Screenshot from 2023-01-02 17-32-24

codefist commented 1 year ago

After messing with this all day I abandoned react native altogether in favor of two native apps. Honestly I think I can develop my app quicker without dealing with all these layers of abstraction.