expo / config-plugins

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

fix(ffmpeg-kit-react-native): fix Android build errors caused by duplicate libc++_shared.so #159

Closed lachenmayer closed 1 year ago

lachenmayer commented 1 year ago

Why

Fixes #31.

The root cause of this is the issue described in the ffmpeg-kit docs:

If a second library which also includes libc++_shared.so is added as a dependency, gradle fails with More than one file was found with OS independent path 'lib/x86/libc++_shared.so' error message.

This is currently breaking our build, so we're using patch-package to apply this diff.

How

Using https://github.com/expo/expo/pull/15863, which allows us to define a android.packagingOptions.pickFirsts property in gradle.properties.

Note that this currently doesn't check if there are any other android.packagingOptions.pickFirsts properties - I'm not even sure what the behavior should be in general (should it be replaced, appended, ...?).

Test Plan

So far, this has only been tested by building our app on EAS, using patch-package to update the packages/ffmpeg-kit-react-native/build/withAndroidFFMPEGPackage.js file.

Before: the gradlew task fails with the following error:

[stderr] Execution failed for task ':app:mergeDebugNativeLibs'.
[stderr] > A failure occurred while executing com.android.build.gradle.internal.tasks.MergeNativeLibsTask$MergeNativeLibsTaskWorkAction
[stderr]    > 2 files found with path 'lib/arm64-v8a/libc++_shared.so' from inputs:
[stderr] - /home/expo/.gradle/caches/transforms-3/2cc1c6bf49a4b55c6e81278f0aa6c079/transformed/jetified-react-native-0.70.5-debug/jni/arm64-v8a/libc++_shared.so
[stderr]       - /home/expo/.gradle/caches/transforms-3/2a1d5e98bc03f10f84a5b972b15ae4ac/transformed/jetified-ffmpeg-kit-https-gpl-5.1/jni/arm64-v8a/libc++_shared.so
[stderr]      If you are using jniLibs and CMake IMPORTED targets, see
[stderr]      https://developer.android.com/r/tools/jniLibs-vs-imported-targets
[stderr] * Try:
[stderr] > Run with --stacktrace option to get the stack trace.
[stderr] > Run with --info or --debug option to get more log output.
[stderr] > Run with --scan to get full insights.

After: build succeeds.

eprice122 commented 1 year ago

I was seeing the same issue and this patch worked for me as well