3

I try to add a local .aar file to the project as it is described here, because I don't want to implement this routine each time when I change my library code.

So in my project build.gradle file I added:

repositories {
    mavenCentral()
    flatDir {
        dirs 'libs'
    }
}

Both my library and my app have two flavours - alphaTest and myRelease. I want each library to be added strictly to the corresponding flavour of the app.

And in build.gradle of my app I have the following dependencies block:

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar', '**/*.aar'])
    compile 'com.android.support:appcompat-v7:23.0.0'
    alphaTestCompile files ('libs/myLib-alphaTest-release.aar')
    myReleaseCompile files('libs/myLib-myRelease-release.aar')
}

Unfortunately as a result I always receive this kind of error:

Error:Project myApp: Only Jar-type local dependencies are supported. Cannot handle: C:\Users\...\myApp\libs\myLib-myRelease-release.aar

I tryed to use this format

alphaTestCompile  ('my.package:libs/myLib-alphaTest-release:0.1@aar')

and also this

alphaTestCompile  (name:'myLib-alphaTest-release', ext:'aar')

but in this case the gradle cannot event resolve the files.

How can I make .aar files also be compiled?

Community
  • 1
  • 1
user2957954
  • 1,221
  • 2
  • 18
  • 39
  • Possible duplicate of [How to use local aar dependency?](http://stackoverflow.com/questions/28869213/how-to-use-local-aar-dependency) – sschuberth Apr 19 '17 at 08:45

1 Answers1

3

Below is what I config for using aar file:

//dependencies
compile fileTree(include: ['*.jar'], dir: 'libs') // dont change anything here
compile(name: 'yourLib', ext: 'aar') // yourLib.aar is put in libs folder

repositories {
     flatDir {
         dirs 'libs'
     }
}
Kingfisher Phuoc
  • 8,052
  • 9
  • 46
  • 86