The problem
i am trying to trim and compress a video using two libraries: Silicompressor and k4l-video-trimmer. the problem is both libraries use mp4parser but different versions of it. k4l-video-trimmer is using version 1.1.20 as a dependency in build.gradle and Silicompressor is using version 1.0.6 as a jar file. now the project builds fine but when i try to run it, i get the error:
More than one file was found with OS independent path 'builddef.lst'
The things i have already tried
Exclude builddef.lst in packaging options
i added these lines in app level build.gradle:
android {
packagingOptions {
exclude 'builddef.lst'
exclude 'version.txt'
exclude 'isoparser-default.properties'
}
}
and then i got another error which i was unable to solve:
Program type already present: com.coremedia.iso.BoxParser Message{kind=ERROR, text=Program type already present: com.coremedia.iso.BoxParser, sources=[Unknown source file], tool name=Optional.of(D8)}
Exclude mp4parser from k4l-video-trimmer
i used
implementation ('life.knowledge4:k4l-video-trimmer:1.0') {
exclude group: 'com.googlecode.mp4parser'
}
instead of
implementation 'life.knowledge4:k4l-video-trimmer:1.0'
and now the project runs and crashes when i try to trim a video.
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/googlecode/mp4parser/FileDataSourceViaHeapImpl; at life.knowledge4.videotrimmer.utils.TrimVideoUtils.genVideoUsingMp4Parser(TrimVideoUtils.java:72) at life.knowledge4.videotrimmer.utils.TrimVideoUtils.startTrim(TrimVideoUtils.java:65) at life.knowledge4.videotrimmer.K4LVideoTrimmer$5.execute(K4LVideoTrimmer.java:354) at life.knowledge4.videotrimmer.utils.BackgroundExecutor$Task.run(BackgroundExecutor.java:212) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:428) at java.util.concurrent.FutureTask.run(FutureTask.java:237) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:272) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607) at java.lang.Thread.run(Thread.java:761)
Exclude mp4parser from Silicompressor
i imported Silicompressor's module instead of using dependency line and removed mp4parser's jar file to force the library to use the version 1.1.20. now app runs again but the compressed video has no audio!
Use both versions of mp4parser
i used jarjar to repackage the jar file Silicompressor was using from com.googlecode.mp4parser to org.repackage.com.googlecode.mp4parser. still having the very same issue.
Build.gradle
here's my app level build.gradle file:
apply plugin: 'com.android.application'
configurations {
all*.exclude group: 'com.android.support', module: 'support-v4'
}
android {
compileSdkVersion 27
buildToolsVersion "27.0.3"
defaultConfig {
applicationId "---"
minSdkVersion 16
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
repositories {
google()
jcenter({url "http://jcenter.bintray.com/"})
mavenLocal()
jcenter()
maven { url "http://jzaccone.github.io/SlidingMenu-aar" }
maven { url "https://jitpack.io" }
maven { url 'https://maven.google.com' }
maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
}
/*packagingOptions {
exclude 'builddef.lst'
exclude 'version.txt'
exclude 'isoparser-default.properties'
}*/
}
dependencies {
...
implementation ('life.knowledge4:k4l-video-trimmer:1.0') {
exclude group: 'com.googlecode.mp4parser'
}
implementation 'com.iceteck.silicompressorr:silicompressor:2.1'
}
and THANK YOU FOR YOUR TIME!