title: Exclude class from resulting dex file
body: <p>I have a problem. I have a structure of project looking like this:<br>
  P<br>
  |-SubP1<br>
  |-SubP2</p>
  
  <p>There are two stub classes <strong>android.media.IRemoteDisplay</strong> in both packages. They differ in implementation, but that's not the matter - they will be replaced by system classes when I'll run the app on Android.</p>
  
  <p>However, there is a problem - I can't build the project because dexMerger fails - it says there are two conflicting classes. I can understand that error - after all, there are really two conflicting classes :)</p>
  
  <p>But when I try to exclude these files in build.gradle like this:</p>
  
  <pre><code>sourceSets {
      main {
          java {
              srcDir 'src'
              exclude '**/android/media/**'
          }
      }
  }
  </code></pre>
  
  <p>The compilation fails because it can't find <strong>android.media.IRemoteControlDisplay</strong> class(and it's nested classes).</p>
  
  <p>How can I still use these classes, but exclude them from resulting DEX file?</p>
  
  <p>Please <strong>DON'T</strong> question if it's right to exclude the class from compiled project - it's the right thing to do, I already did it, but manually - by pre-compiling SubP1 and SubP2 to jars and then manually removing IRemoteController.class from these jar files and then including those jars in P.</p>
  
  <p>I'll also be satisfied with that solution:<br>
  1. Build SubP1<br>
  2. Remove IRemoteControlDisplay.class from SubP1.jar<br>
  3. Build SubP2<br>
  4. Remove IRemoteControlDisplay.class from SubP2.jar<br>
  5. Add SubP1.jar and SubP2.jar as dependencies to P<br>
  6. Build P<br>
  If that's possible, please let me know.</p>