Import local aar library

Usually dependency libraries are referred through build.gradle (app) with the web address, but you can also import a local library.

dependencies { compile 'com.android.support:appcompat-v7:23.2.1'
               compile 'com.android.support:design:23.2.1'
               compile 'com.android.support:percent:23.2.1'
}

Reference a local library jar/aar through:

File > New > New Module

After the new module window, comes create new module window with File name and Subproject name.

First is the location of aar file and the second one is the subproject name, which you can select yourself, it is used for local reference.  In this example we will call it imported-aar. There will appear a new build.gradle (Module: imported-aar) in the android project explorer. We can reference it in build.gradle (app) as follows.

dependencies {  compile 'com.android.support:appcompat-v7:23.2.1'
                compile 'com.android.support:design:23.2.1'
                compile 'com.android.support:percent:23.2.1'
                compile project (':imported-aar')
}

Then you need to use Sync Now in the upper right corner of build.gradle (app).

 

Inside the aar libraries are just zip folders with certain structure: Android Tools: Aar Format

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s