title: How to Add and Use an AAR in AndroidStudio Project
body: <p>I am trying to use a custom aar in my android project. I found dozens of examples in StackOverflow and the Web. Many failed at build, none worked. The clearest was at
  <a href="http://kevinpelgrims.com/blog/2014/05/18/reference-a-local-aar-in-your-android-project/" rel="noreferrer">http://kevinpelgrims.com/blog/2014/05/18/reference-a-local-aar-in-your-android-project/</a><br>
  That came closest to working.  </p>
  
  <p>Here's what I did  </p>
  
  <ol>
  <li><p>Successfully created a very simple AAR (Ref.aar) from Ref.java</p>
  
  <pre><code>// Ref.java  
  package com.ramrod.Ref;  
  public class Ref {
      // Square an integer
      public static int
      square(int val) {
          return (val * val);
      }
  }  
  </code></pre></li>
  <li><p>Created a test project (RefTest)  </p></li>
  <li>Created folder 'libs' under RefTest/app  </li>
  <li>Added Ref.aar to libs  </li>
  <li>File->New->New Module->Import .JAR/.AAR Package.  </li>
  <li>Selected Ref.jar as filename->Finish (appeared successful).  </li>
  <li><p>Modified build.gradle</p>
  
  <pre><code>// build.gradle (Module: app)  
  
  apply plugin: 'com.android.application'
  
  android {
      compileSdkVersion 27  
      buildToolsVersion "27.0.3"
      defaultConfig {
          applicationId "com.ramrod.RefTest"
          minSdkVersion 11
          targetSdkVersion 15
      }
      buildTypes {
          release {
              minifyEnabled false
              proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
          }
      }
      repositories {
          flatDir {
              dirs 'libs'
          }
      }
      dependencies {
          compile( name:'Ref', ext:'aar' )
     }
  }  
  </code></pre></li>
  <li>Sync build.gradle (all)  </li>
  <li><p>Added reference to Ref.aar method (square) to onCreate in RefTest main activity.  </p>
  
  <pre><code>int sq = Ref.square( 2 );
  </code></pre></li>
  <li><p>Build->Clean then Build->Rebuild.<br>
  This produced <em>error: cannot find symbol variable Ref</em>  </p></li>
  </ol>
  
  <p>I'm sure I'm doing something naive or just plain dumb, but I can't see it.<br>
  Any help appreciated.</p>