title: Build a jar file that contains its dependencies classes with android-plugin
body: <p>I am writing an android SDK. I am using gradle and android studio.</p>
  
  <p><strong>Legend:</strong></p>
  
  <ul>
  <li>X.jar - a 3rd party jar file. </li>
  <li>Y.jar - my final android SDK jar file, dependence on X.jar.</li>
  <li>someApp - an Android app that uses/dependence on Y.jar.</li>
  </ul>
  
  <p><strong>The Problem:</strong></p>
  
  <p>someApp can not recognize classes in X.jar</p>
  
  <p>I've searched (for almost a day) ways to generate Y.jar with also classes of X.jar (instead of just including X.jar file inside) but unfortunately I've failed. Many solutions I found were not clear enough or didn't fit my case. </p>
  
  <p>I would very much appreciate your help and guidance.</p>
  
  <p>Here is my relevant code snippet (based on this <a href="https://stackoverflow.com/a/19037807/3510966">answer</a>):</p>
  
  <p>build.gradle code of my SDK project - creating Y.jar:</p>
  
  <pre><code>apply plugin: 'com.android.library'
  
  android {
      compileSdkVersion 21
      buildToolsVersion "21.1.2"
  
      defaultConfig {
          minSdkVersion 18
          targetSdkVersion 21
          versionCode 1
          versionName "1.0"
      }
      buildTypes {
          release {
              minifyEnabled false
              proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
          }
      }
  
      sourceSets {
          main {
              java {
                  srcDir 'src/main/java'
              }
              resources {
                  srcDir 'src/../libs'
              }
          }
      }
  }
  
  dependencies {
      compile 'com.android.support:appcompat-v7:21.0.3'
      compile files('libs/X.jar')
  }
  
  task clearJar(type: Delete) {
      delete 'build/outputs/Y.jar'
  }
  
  task makeJar(type: Copy) {
  
      from('build/intermediates/bundles/release/')
      into('build/outputs/')
      include('classes.jar')
      rename ('classes.jar', 'Y.jar')
  }
  
  makeJar.dependsOn(clearJar, build)
  </code></pre>
  
  <p>running 'gradlew makeJar' generates Y.jar in build/outputs directory.</p>