Adding local .aar files to Gradle build using “flatDirs” is not working

Building upon Josiah’s answer, here’s how I got it to work.

Following his instructions (under edit) (File -> New-> New Module -> Import .JAR/.AAR) and import your .AAR.

Then in your project build.gradle (not the top level one, the one under ‘app’) add the following (in the dependencies section):

dependencies {
    compile project(':Name-Of-Your-Project')
}

Note Name-Of-Your-Project should match the name of the folder that was added after you imported the AAR file (at the same level as app/.idea under the top most level folder). Or to put it another way…

MyApplication
  .idea
  app
  build.gradle (here's where to add compile project(':ProjectName') to dependency section)
  ProjectName (added automatically after importing, matching the name of your aar file)
  build
  gradle
  etc

This worked for me running Android Studio 0.8.0. Don’t forget to synchronize gradle (using toolbar button or in File->Synchronize) after you do this.

(Thanks to Josiah for getting me going in the right direction)

(Note: prior to this I tried adding it to the libs folder, trying to manipulate the top level build.gradle and the app level build.gradle, but none of that worked for my aars files–jar’s will work fine, but not the aar files)

Leave a Comment