Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add .aar dependency in library module?

I am having one .aar file of one library module.
I want to use it as a library or dependency in my other project's library module.
How do I do it?

I tried options provided at below links:
http://kevinpelgrims.com/blog/2014/05/18/reference-a-local-aar-in-your-android-project/

It works only if I add .aar reference in my project's application module. But not working in library module.

Thanks.

like image 232
Swati Avatar asked Jan 13 '16 11:01

Swati


People also ask

What is .AAR file in Android Studio?

An AAR file contains a software library used for developing Android apps. It is structurally similar to an . APK file (Android Package), but it allows a developer to store a reusable component that can be used across multiple different apps.

Where is the libs folder in Android Studio?

How to find the libs folder in Android Studio? If you are unable to find the libs folder in Android studio then open your android project in “Project” mode If the project is already opened in the “Android” mode. Then go to Your Project Name > app > libs and right-click on it and paste the downloaded JAR files.


1 Answers

Follow this setting and you will able to add .aar dependency to library module

build.gradle (Project: ....)

allprojects {     repositories {         jcenter()         mavenCentral()         flatDir {             dirs 'libs'             dirs project(':library_module').file('libs')         }     } } 

build.gradle (Module: app)

dependencies {     ...     compile project(':library_module') } 

build.gradle (Module: library_module)

dependencies {     ...     compile(name:'aar_file_name', ext:'aar') } 

settings.gradle (Project Settings)

include ':app', ':library_module' 
like image 181
Linh Avatar answered Sep 28 '22 01:09

Linh