Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Export Android Library as AAR file

I have created a library module in my project. Now, I want to share/publish this library with others. Sharing a .aar file would be fine for now.

I went through the article - https://developer.android.com/studio/projects/android-library and found the following options.

  1. When you want to build the AAR file, select the library module in the Project window and then click Build > Build APK.
  2. However, if you want to share your AAR file separately, you can find it in project-name/module-name/build/outputs/aar/ and you can regenerate it by clicking Build > Make Project.

I have tried these two options, but couldn't find /aar folder in the path project-name/module-name/build/outputs/

This is the first time I am building a library that needs to be shared with others.

Is there something else I need to do? Please share your thoughts.

like image 942
Suneesh Ambatt Avatar asked May 10 '18 07:05

Suneesh Ambatt


People also ask

Is AAR same as jar?

Unlike JAR files, AAR files offer the following functionality for Android applications: AAR files can contain Android resources and a manifest file, which allows you to bundle in shared resources like layouts and drawables in addition to Java classes and methods.

What is an AAR file Android?

In addition to JAR files, the Android uses a binary distribution format called Android ARchive(AAR). The . aar bundle is the binary distribution of an Android Library Project. An AAR is similar to a JAR file, but it can contain resources as well as compiled byte-code.

How do I extract a .AAR file?

In android studio, open the Project Files view. Find the . aar file and double click, choose "arhcive" from the 'open with' list that pops up. This will open a window in android studio with all the files, including the classes, manifest, etc.


1 Answers

You should do it using gradle. Just follow these steps and you will get .aar file:

1) At right side of your android studio there is a pane name Gradle. Open it and then do open library portion and run assemble. Like in the picture below.

enter image description here

2) When it is successfully ran just go to your library folder and you will find your .aar files there.

C:\projectPath\libraryPath\build\outputs\aar
like image 104
Umair Avatar answered Sep 21 '22 08:09

Umair