title: Android dependency conflict with jar embedded in aar
body: <p>I am using an Android library project by importing the aar as an app module. The app compiles fine in debug mode but when I try to compile in release I get the following error :</p>
  
  <pre><code>Error: Program type already present: com.google.gson.DefaultDateTypeAdapter
  </code></pre>
  
  <p>So I dug around in my dependencies for gson and found out that the aar file has a bunch of embedded jar files included in it, and it seems to be conflicting with my external dependencies, notably Retrofit, OkHttp, and Gson</p>
  
  <p><a href="https://i.stack.imgur.com/X9Y6f.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/X9Y6f.png" alt="enter image description here"></a></p>
  
  <p>I have tried to exclude group com.google.code.gson when I import the aar module but no luck, it doesn't change anything:</p>
  
  <pre><code>implementation(project(':ONprintWS')) {
      exclude group: 'com.google.code.gson'
  }
  </code></pre>
  
  <p>I also thought I could maybe remove the retrofit dependencies in my build.gradle, seeing as how they are included from the aar but when I do my classes can't find the retrofit / gson packages anymore.</p>
  
  <p>I have asked the SDK maintainer to rebuild the SDK without the embedded jar (using transitive dependencies instead) but it might not happen for awhile, is there anyway to remove the embedded jars?</p>
  
  <p><strong>EDITED to show gradle excludes, still not working</strong></p>
  
  <pre><code>//Retrofit
  implementation 'com.squareup.retrofit2:retrofit:2.4.0'
  implementation "com.google.code.gson:gson:2.8.5"
  implementation("com.squareup.retrofit2:converter-gson:2.4.0") {
      exclude group: "com.google.code.gson"
  }
  implementation "com.squareup.retrofit2:adapter-rxjava2:2.4.0"
  implementation 'com.squareup.okhttp3:logging-interceptor:3.10.0'
  
  // ONprintWS SDK
  implementation 'io.realm:realm-gradle-plugin:5.3.0'
  implementation(project(':ONprintWS')) { // v1.0.4
      exclude group: "com.squareup.retrofit2"
      exclude group: "com.squareup.okhttp3"
      exclude group: "com.google.code.gson"
  }
  </code></pre>