title: Using different versions of same library - More than one file was found with OS independent path 'builddef.lst'
body: <h1>The problem</h1>
  
  <p>i am trying to trim and compress a video using two libraries: <a href="https://github.com/Tourenathan-G5organisation/SiliCompressor" rel="nofollow noreferrer">Silicompressor</a> and <a href="https://github.com/titansgroup/k4l-video-trimmer" rel="nofollow noreferrer">k4l-video-trimmer</a>.
  the problem is both libraries use <a href="https://github.com/sannies/mp4parser" rel="nofollow noreferrer">mp4parser</a> 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:</p>
  
  <blockquote>
    <p>More than one file was found with OS independent path 'builddef.lst'</p>
  </blockquote>
  
  <h1>The things i have already tried</h1>
  
  <h2>Exclude builddef.lst in packaging options</h2>
  
  <p>i added these lines in app level build.gradle:</p>
  
  <pre><code>android {
      packagingOptions {
          exclude 'builddef.lst'
          exclude 'version.txt'
          exclude 'isoparser-default.properties'
      }
  }
  </code></pre>
  
  <p>and then i got another error which i was unable to solve:</p>
  
  <blockquote>
    <p>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)}</p>
  </blockquote>
  
  <h2>Exclude mp4parser from k4l-video-trimmer</h2>
  
  <p>i used</p>
  
  <pre><code>implementation ('life.knowledge4:k4l-video-trimmer:1.0') {
      exclude group: 'com.googlecode.mp4parser'
  }
  </code></pre>
  
  <p>instead of</p>
  
  <pre><code>implementation 'life.knowledge4:k4l-video-trimmer:1.0'
  </code></pre>
  
  <p>and now the project runs and crashes when i try to trim a video.</p>
  
  <blockquote>
    <p>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)</p>
  </blockquote>
  
  <h2>Exclude mp4parser from Silicompressor</h2>
  
  <p>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!</p>
  
  <h2>Use both versions of mp4parser</h2>
  
  <p>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.</p>
  
  <h1>Build.gradle</h1>
  
  <p>here's my app level build.gradle file:</p>
  
  <pre><code>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'
  }
  </code></pre>
  
  <p>and THANK YOU FOR YOUR TIME!</p>