Generate an Android Archive(AAR) Using Android Studio and Add to an Android Project

Narendra Harny
The Startup
Published in
4 min readDec 7, 2020

This article provides Information for creating AAR for an Android Library module and using It with another Android Project.

Photo by Mark Boss on Unsplash

I have posted an article for creating an Android Library module in an Android Project and using that with the UI app module.

Please see the article if you need to know about creating the Library module in Android Project.

In this article, I will explain how we can generate the Android Archive(AAR) file for an Android Library module and Use that in different Android projects so that we can understand that Library creation can save our redevelopment time cost by using the same module in different projects.

I will use Android Studio 4.0.2 and the same Project mentioned in the attached article.

I have created a project and a Library module It is shown below.

Project Structure

It is mentioned that I have created a Library Module named currentTimeLib and I am using that module successfully within the project, now I will generate the AAR file and I will Import the AAR file into a different Android Project.

If you already know about creating the Library module then you can follow the steps directly.

If you want to Implement it then either complete the previous article (Click here) or pull the code from Git and try that(Click here).

Please follow the steps>>

Step 1: Start the Android Studio and open the project where you want to generate the AAR file.

Step 2: Click the Gradle option in the right most corner of Android Studio.

Step3: You will see the App name in the window, please unfold the options in the sequence shown below.

It might take a few minutes, If the Build task is successfully completed It will show the message.

Step4: The generated AAR files will be located here(According to your Library name)

Step5: Now we can add the archive file into another Android Project so create a new Android Project.

Step6: After creating a new project >> Click on File>> Project Structure >> Modules >> “+” icon >>

Next>> The below window will have an option to select “Import AAR/JAR”

Next>> Click on next after selecting the “Import AAR/JAR” and in the next window select the AAR file path and click Finish.

Note: Take the AAR file generated in the previous project or use the AAR file you want to add.

Step7: Verify in settings.gradle file, the library module will be included.

Step8: Add the library module into the module Gradle file where this AAR file implementation is needed.

app module gradle

Step 9:Sync the project” and wait for the build successful.

Step 10: Verify the classes available in the Library module are accessible in the module you have added to the AAR file.

Classes available from the AAR Library module

Step11: Now you can write the code for using the AAR library module in your Android Project.

Thanks!! Please add comments If you face any issues while implementing.

Thanks for Reading! If this article was helpful. Please hit the clap!

Follow on medium https://medium.com/@narendra147h

Connect on Linked In: linkedin.com/in/narendraharny

Please Follow & subscribe to Make Android Publication by Narendra K H for prompt updates on Android platform-related blogs.

Thank you!

--

--

Narendra Harny
The Startup

Connect on https://medium.com/make-android | Write On, Android AOSP & Applications | Python | DevOps | Java | C++ | Kotlin | Shell | Linux | Android Auto | IVI