maitrungduc1410 / react-native-video-trim

Video trimmer for React Native App
MIT License
37 stars 14 forks source link

Duplicate class error on Android for ffmpeg #48

Closed ISnowFoxI closed 1 week ago

ISnowFoxI commented 1 month ago

First of all, thank you for this library.

I was using ffmpeg-kit-react-native to edit video metadata on Android. I also needed a way to trim videos, so I used this library. I would get multiple Duplicate class errors when building for Android because of mismatched FFmpeg packages in the project. Using

ext {
    ffmpegKitPackage = "<package name>"
}

didn't help me.

I suggest adding additional steps to the readme for conflicting install cases. My solution was editing the android/app/build.gradle file like so:

dependencies {
    ...
     modules {
        module('com.arthenica:ffmpeg-kit-https') {
            replacedBy 'com.arthenica:ffmpeg-kit-min'
        }
    }
}

I found the above solution in this blog post: https://tomgregory.com/gradle/how-to-exclude-gradle-dependencies/#option-3-module-replacement-exclude-alternative

I've also opened an issue in ffmpeg-kit repo here -> https://github.com/maitrungduc1410/react-native-video-trim/issues/new for further discussion if needed.

maitrungduc1410 commented 1 month ago

hi, ffmpeg-kit-react-native also uses ffmpegKit under the hood, so we can just sync the version between both and it should be fine (technically)

buildscript {
    ext {
        ffmpegKitPackage = "full" // default "min"

        ffmpegKitPackageVersion = "5.1.LTS" // default 6.0-2
    }

You just need to find out which ffmpegKit version of ffmpeg-kit-react-native, then use the above code

maitrungduc1410 commented 1 month ago

upon checking latest source of ffmpeg-kit-react-native, the default version is com.arthenica:ffmpeg-kit-https:6.0.2

then to make it work with my lib you should edit android/build.gradle like:

buildscript {
    ext {
        ffmpegKitPackage = "https"

        ffmpegKitPackageVersion = "6.0.2"
    }
ISnowFoxI commented 1 month ago

@maitrungduc1410 thank you for getting back, I think I tested this and it didn't work. That said, I'll test it once more and get back to you. I was trying to use the min package but It has been over a month since so I can't remember the exact details.

maitrungduc1410 commented 1 month ago

@ISnowFoxI just test from your end first, if the error still occurs then you can give me exact version of ffmpeg-kit-react-native and react-native-video-trim (they're in package-lock.json), and I'll do a check from my end

ISnowFoxI commented 1 week ago

I am going to close this issue as I haven't had the time to test it yet, I'll re-open it if I have the time to test it. Thank you