Issue
I am trying to enable package of ffmpeg-kit-react-native in react-native.
The sample commands given in the href="https://github.com/tanersener/ffmpeg-kit/tree/main/react-native#3-using" rel="noreferrer">example executes successfully. But I want to use libwebp
for converting gif files to webp which is under package named video
. As instrcuted . I have to enable the package to use some libraries.
2.2.1 Enabling a Package on Android Edit android/build.gradle file and add the package name in ext.ffmpegKitPackage variable.
ext { ffmpegKitPackage = "<package name>" }
So I added a line in the node_module/ffmpeg-kit-react-native/android/build.gradle
android {
compileSdkVersion 30
defaultConfig {
minSdkVersion safeExtGet('ffmpegKitPackage', 'https').contains("-lts") ? 16 : 24
targetSdkVersion 30
versionCode 451
versionName "4.5.1"
}
buildTypes {
release {
minifyEnabled false
}
}
lintOptions {
disable 'GradleCompatible'
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
rootProject.ext.ffmpegKitPackage = "video" // Added this line here
}
Error:
* What went wrong:
Execution failed for task ':app:mergeDebugNativeLibs'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.MergeJavaResWorkAction
> 2 files found with path 'lib/arm64-v8a/libc++_shared.so' from inputs:
- C:\Users\ADMIN\.gradle\caches\transforms-3\7403ebe5571a2ce5a6a5fc9876af4814\transformed\jetified-react-native-0.66.4\jni
- C:\Users\ADMIN\.gradle\caches\transforms-3\4be54e44fe38656741a8345504588323\transformed\jetified-ffmpeg-kit-video-4.5.1-1\jni
If you are using jniLibs and CMake IMPORTED targets, see
https://developer.android.com/r/tools/jniLibs-vs-imported-targets
I have tried ./gradlew clean but problem is still there. How to fix this error? Thanks
Solution
add this in your node_module/ffmpeg-kit-react-native/android/build.gradle
android{
packagingOptions {
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'
}
rootProject.ext.ffmpegKitPackage = "video"
}
ffmpeg-kit-react-native has already talked about this error here. https://github.com/tanersener/ffmpeg-kit/wiki/Tips#2-depending-another-android-library-containing-libc_sharedso
Answered By - UHS
Answer Checked By - Marie Seifert (JavaFixing Admin)