title: Android Studio - Gradle dependencies - How to Exclude `bolts` from `facebook`?
body: <blockquote>
    <p>Error:Execution failed for task
    ':app:transformClassesWithJarMergingForDebug'.</p>
    
    <blockquote>
      <p>com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry:
      bolts/AggregateException.class</p>
    </blockquote>
  </blockquote>
  
  <p>That's how the error looks like. I know that <code>bolts</code> is used in 3 of my dependencies, <code>com.facebook.fresco:fresco:0.10.0</code>, <code>com.parse:parse-android:1.13.1</code> and a jar <code>ePOS2.jar</code>.</p>
  
  <p>I have tried multiple solutions, starting with </p>
  
  <pre><code> compile('com.facebook.fresco:fresco:0.10.0') {
           exclude group: 'com.parse.bolts', module: 'bolts-android'
       }
  </code></pre>
  
  <p>But I still get the error. I have also tried to exclude some parts from <code>com.parse:parse-android1.13.1</code> as shown <a href="https://stackoverflow.com/questions/28791817/android-studio-gradle-error-multiple-dex-files-define">in this post</a>  but then I get the missing classes error then.</p>
  
  <p>I also enabled <code>multidex</code> as shown in <a href="https://stackoverflow.com/questions/26609734/how-to-enable-multidexing-with-the-new-android-multidex-support-library">this post</a> but the error still occurs.  </p>
  
  <p>I tried to exclude <code>com/parse/bolts/AggregateException.class</code> as shown <a href="https://stackoverflow.com/questions/19575474/gradle-how-to-exclude-a-particular-package-from-a-jar">in this post</a>, still the error occurs.</p>
  
  <p>The strangest is that if I enable <code>InstantRun</code> I can run the app but crashes when it uses a certain class from the jar. </p>
  
  <blockquote>
    <p>java.lang.UnsatisfiedLinkError:
    com.android.tools.fd.runtime.IncrementalClassLoader$DelegateClassLoader</p>
  </blockquote>
  
  <p>So, I thought if is possible to exclude that certain class <code>AggregateException.class</code> either from jar or <code>com.parse:parse-android:1.13.1</code>?</p>
  
  <p><strong>EDIT</strong></p>
  
  <blockquote>
    <p>compile('com.facebook.fresco:fresco:0.10.0') {
            exclude module: 'bolts-android'
        }</p>
  </blockquote>
  
  <p>OR</p>
  
  <blockquote>
    <p>compile('com.facebook.fresco:fresco:0.10.0') {
            exclude group: 'com.parse.bolts',
                    module: 'bolts-android'
        }</p>
  </blockquote>
  
  <p>I have tried to exclude <code>bolts</code> from <code>com.facebook.fresco:fresco:0.10.0</code> but whatever I do they still appear:</p>
  
  <pre><code>    +--- com.android.support:multidex:1.0.1                                  
  +--- com.android.support:design:23.3.0
  |    +--- com.android.support:appcompat-v7:23.3.0
  |    |    +--- com.android.support:support-vector-drawable:23.3.0
  |    |    |    \--- com.android.support:support-v4:23.3.0
  |    |    |         \--- com.android.support:support-annotations:23.3.0
  |    |    +--- com.android.support:animated-vector-drawable:23.3.0
  |    |    |    \--- com.android.support:support-vector-drawable:23.3.0 (*)
  |    |    \--- com.android.support:support-v4:23.3.0 (*)
  |    +--- com.android.support:support-v4:23.3.0 (*)
  |    \--- com.android.support:recyclerview-v7:23.3.0
  |         +--- com.android.support:support-v4:23.3.0 (*)
  |         \--- com.android.support:support-annotations:23.3.0
  +--- com.makeramen:roundedimageview:2.2.1
  +--- com.facebook.fresco:fresco:0.10.0
  |    +--- com.facebook.fresco:drawee:0.10.0
  |    |    +--- com.android.support:support-v4:23.1.1 -&gt; 23.3.0 (*)
  |    |    \--- com.facebook.fresco:fbcore:0.10.0
  |    +--- com.facebook.fresco:fbcore:0.10.0
  |    \--- com.facebook.fresco:imagepipeline:0.10.0
  |         +--- com.android.support:support-v4:23.1.1 -&gt; 23.3.0 (*)
  |         +--- com.nineoldandroids:library:2.4.0
  |         +--- com.facebook.fresco:fbcore:0.10.0
  |         +--- com.facebook.fresco:imagepipeline-base:0.10.0
  |         |    +--- com.android.support:support-v4:23.1.1 -&gt; 23.3.0 (*)
  |         |    +--- com.nineoldandroids:library:2.4.0
  |         |    +--- com.facebook.fresco:fbcore:0.10.0
  |         |    \--- com.parse.bolts:bolts-android:1.1.4 !!! HERE
  |         \--- com.parse.bolts:bolts-android:1.1.4  !!! HERE
  +--- com.facebook.fresco:imagepipeline-okhttp:0.7.0
  |    +--- com.squareup.okhttp:okhttp:2.3.0
  |    |    \--- com.squareup.okio:okio:1.3.0
  |    +--- com.facebook.fresco:imagepipeline:0.7.0 -&gt; 0.10.0 (*)
  |    \--- com.facebook.fresco:fbcore:0.7.0 -&gt; 0.10.0
  +--- com.parse:parse-android:1.13.1
  |    \--- com.parse.bolts:bolts-tasks:1.4.0
  \--- uk.co.chrisjenx:calligraphy:2.2.0
       \--- com.android.support:appcompat-v7:23.1.1 -&gt; 23.3.0 (*)
  </code></pre>