title: Use local jar as a dependency in my Gradle Java project
body: <p>I have a local jar file named <code>mylib.jar</code>. I want to used it as a dependency in my Gradle Java project.</p>
  
  <p>This is what I tried:</p>
  
  <p>I created a <code>libs/</code> folder under project root. I put the jar file under <code>libs/</code> folder.</p>
  
  <pre><code>MyProject
   -&gt;libs/mylib.jar
   -&gt;build.gradle
   -&gt;src/...
  </code></pre>
  
  <p>In my build.gradle:</p>
  
  <pre><code>apply plugin: 'java-library'
  
  group 'com.my.app'
  version '1.0-SNAPSHOT'
  
  sourceCompatibility = 1.8
  
  repositories {
      mavenCentral()
  
      flatDir {
          dirs 'libs'
      }
   }
  
  dependencies {
      testCompile group: 'junit', name: 'junit', version: '4.12'
      api files('libs/mylib.jar')
  }
  </code></pre>
  
  <p>But I can't access the public classes defined in <code>mylib.jar</code> in my project code. Why?</p>
  
  <p><strong>===== More information =====</strong></p>
  
  <p>The content of my jar:</p>
  
  <pre><code>mylib.jar
      &gt; com.my.jar.package
        &gt;ClassFromJar.class
  </code></pre>
  
  <p>Here is how I use the jar:</p>
  
  <pre><code>// Compilation error: Cannot resolve symobl 'ClassFromJar'
  import com.my.jar.package.ClassFromJar;
  
  public class MyEntryPoint {
      // Compilation error: Cannot resolve symbol 'ClassFromJar'
      ClassFromJar instance = new ClassFromJar();
  }
  </code></pre>