In an Android Gradle build, how to exclude dependencies from an included jar file?
<p>In my Android project, I use a library that comes as a jar. 
I include it in the dependencies section like so:</p>

<pre><code>dependencies {
    ...

    compile files('libs/thethirdpartylibrary.jar')
    ...
}
</code></pre>

<p>I also want to use the okhttp library, which I include like this:</p>

<pre><code>compile ('com.squareup.okhttp:okhttp:2.7.5')
</code></pre>

<p>(This particular version of okhttp depends on okio 1.6.0.)</p>

<p>The problem is that the thirdparty jar library depends on okio v0.9.0 and what's worse, bundles it.</p>

<p>As a result, I get a dex conflict error at build time.</p>

<p>I was able to resolve this by manually removing okio from the jar file and this seems to work. But I'm wondering if there's a way to do this in gradle.</p>

<p>My question: Can I remove bundled, transitive ( &lt;- I hope I'm using this word the right way) dependencies from an included jar during build-time with gradle?</p>