Excluding multiple transitive dependencies from all configurations
<p>I am facing a problem to develop an android project in Android Studio.</p>

<p>I am using multiple *.jar extension files as libraries for my project.
But, they have common classes between them, that is, classes with same class name and same package name. The *.jar extension files are: rt.jar and tools.jar. The "rt.jar" file was obtained from OpenJDK6 jre binary file for Debian OS (x86). The "tools.jar" file was obtained from Beads Library file, that is, it was obtained from "Beads.zip" file, and the "Beads.zip" file is available at: <a href="http://www.beadsproject.net/" rel="nofollow">http://www.beadsproject.net/</a>. I am developing a new Beads-based android project in Android Studio. By the way, I need a JavaSound implementation for Android OS, because Beads library needs a JavaSound implementation. So, I wanted to use the javaRT from OpenJDK in the Beads-based android project in Android Studio, but I found the problem of the redundant *.class extension files in this project libraries "rt.jar" and "tools.jar".</p>

<p>By the way, I need to exclude the redundant *.class extension files in the "app execution process, in debug mode" (The respective button is called: Run 'app', in Android Studio), or in the "apk building process", with the Gradle tool use, that is, in the "classes.dex" file creation/manipulation.</p>

<p>I searched the web, and I found some information in the stackoverflow.com website... Then, I used "multiDexEnabled true" in the "defaultConfig" definition to fix some previous problems.</p>

<p>So, I knew I could use "configurations.compile.transitive = false" to try resolve my problem, but it didn't work. By the way, I tried the use of:</p>

<pre><code>configurations {
all*.exclude group: 'sun', module: 'sun.applet'
all*.exclude group: 'sun', module: 'sun.tools.jar'
}
</code></pre>

<p>, or</p>

<pre><code>configurations {
all*.exclude group: 'sun', module: 'sun.applet'
}

configurations {
all*.exclude group: 'sun', module: 'sun.tools.jar'
}
</code></pre>

<p>, for example, but they didn't work, neither.</p>

<p>And I tried:</p>

<pre><code>dependencies {
compile files('lib/tools.jar') {
exclude group: 'sun', module: 'sun.applet'
exclude group: 'sun', module: 'sun.tools.jar'
}
}
</code></pre>

<p>, but it didn't work, neither.</p>

<p>I don't know if these statements are useful to exclude redundant *.class extension Java files in this apk building process, but I think they aren't.</p>

<p>The link of the web page cited in this question is:<br>
<a href="https://discuss.gradle.org/t/how-can-i-exclude-all-transitive-dependencies/6875" rel="nofollow">https://discuss.gradle.org/t/how-can-i-exclude-all-transitive-dependencies/6875</a><br>
.</p>

<p>Thanks for any help.</p>