Search code examples
androidandroid-studioaar

Only Jar-type local dependencies are supported when adding aar


I'm trying to add an aar file as a local dependency, including it in my libs folder adding this line to my build.gradle:

compile fileTree(dir: 'libs', include: ['*.jar', '*.aar'])

But I'm getting the next error:

Project app: Only Jar-type local dependencies are supported. Cannot handle: /path/to/my/aar/filename.aar

How can I locally add the aar to my project?


Solution

  • Update

    I just remember there is a much better way to do it. In the Android Studio, click File -> New -> New Module -> Import .JAR/.AAR Package and select your aar. Then we can use that AAR just like a module of a project.

    Old answer

    Including AAR requires some work and here're some guidelines:

    An useful script: https://github.com/adwiv/android-fat-aar

    Create on your own with this article: https://medium.com/@notestomyself/how-to-include-external-aar-file-using-gradle-6604b378e808

    However, I don't think including AAR is a good practice. Because there'll be no source code and you have to manage AAR's dependencies and its version manually. Sometimes some annotations defined in the AAR may break proguard.