title: Android Studio: add a custom jar as dependency
body: <p>I have a java REST project that communicates with an Android Project, using <a href="https://martinfowler.com/eaaCatalog/dataTransferObject.html" rel="nofollow noreferrer">DTO  classes</a>.</p>
  
  <p>Initially, I had created DTO classes duplicated in both projects, but now I have a new Java/JAR project with this common DTO classes and I want to use this library in both projects (Rest and Android).</p>
  
  <p>I pasted the JAR file in <code>app/libs</code> folder in Android Studio.</p>
  
  <p>I added this file as a Jar dependency in Android Studio.</p>
  
  <p>The build.gradle file contains the jar's reference
  compile files('libs/my-custom-jar-1.0.0.jar')</p>
  
  <pre><code>dependencies {
      compile files('libs/my-custom-jar-1.0.0.jar')
      compile fileTree(include: ['*.jar'], dir: 'libs')
  }
  </code></pre>
  
  <p>I followed the <a href="https://stackoverflow.com/questions/25660166/how-to-add-a-jar-in-external-libraries-in-android-studio">steps described here</a> but doesn't work. The classes packaged in the JAR file are not available.</p>
  
  <p>I also try to "Invalidate Cache and Restart" Android Studio</p>
  
  <p>[]'s</p>
  
  <p><strong>Edit</strong></p>
  
  <p>The file build.gradle</p>
  
  <pre><code>dependencies {
      compile fileTree(dir: 'libs', include: ['*.jar'])
      androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
          exclude group: 'com.android.support', module: 'support-annotations'
      })
      androidTestCompile 'com.google.code.findbugs:jsr305:3.0.2'
      compile project(':com.custom.dialog')
      compile project(':zxing_standalone')
      compile 'com.android.support:appcompat-v7:26.0.2'
      compile 'com.android.support.constraint:constraint-layout:1.0.2'
      compile 'com.xxxxxxxx.android:library:1.0.23@aar', { transitive = true }
      compile 'com.google.code.gson:gson:2.2.4'
      compile 'com.squareup.retrofit2:retrofit:2.3.0'
      compile 'com.squareup.retrofit2:converter-scalars:2.1.0'
      compile 'com.squareup.retrofit2:converter-gson:2.3.0'
      compile 'com.squareup.okhttp3:okhttp:3.9.0'
      compile 'com.squareup.okhttp3:logging-interceptor:3.9.0'
      compile 'com.android.support:design:26.0.2'
      compile 'commons-io:commons-io:2.0.1'
      compile 'org.apache.commons:commons-lang3:3.5'
      compile files('libs/my-custom-jar-1.0.0.jar')
  }
  </code></pre>