Different Ways to Create aar File in Android Studio
Last Updated :
17 Mar, 2021
Android Studio can be used to create an Android archive file (*.aar) that can contain classes and methods that make use of Android classes and related files. Like creating the Jar file, an Android project must be created first, then the Android library module can be created and added. The main difference between a Jar and an AAR is that AAR s include resources such as layouts, drawables, etc. . For example if you have multiple apps that use the same login screen, with Jar's you could share classes but not the layout, styles, etc., you still had to duplicate them. So in this article, we are going to see what are .aar files, how to open them in Android Studio, and five different ways to create .aar files in Android Studio.
What is the .aar file in Android Studio?
An Android library is structurally the same as an Android app module. It can include everything needed to build an app, including source code, resource files, and an Android manifest. However, instead of compiling into an APK that runs on a device, an Android library compiles into an Android Archive (AAR) file that you can use as a dependency for an Android app module. 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.
- AAR files can contain C/C++ libraries for use by the app module's C/C++ code.
In addition to JAR files, 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. 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.
How to open .aar files in Android Studio?
- Open Android Studio
- go to Project Files view.
- Find the .aar file and double click, choose "archive" 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
Different Ways To Generate .aar Files in Android Studio
Method 1
Step 1: Creating AAR
If you have already created AAR then you can skip this step and jump to generate AAR. If you haven't created AAR then follow these steps: Navigate to File > New > New Module.
Then select "Android Library" from the options and click the next button.
Step 2: Generate AAR
Go to Gradle at the top-right pane in android studio follow the below steps. Gradle > Drop down library name > tasks > build > assemble or assemble release
AAR will be generated in build/outputs/aar/
.aar filesMethod 2
If you have set-up your library as an Android library that is if you have done with then follow the below steps:
- Apply plugin:'com.android.library' statement in its build.gradle file
- This will output an .aar when it's built.
- It will show up in the build/outputs/aar/ directory in your module's directory.
You can create a new Android Library using File > New Module and selecting the "Android Library" type as already shown in Method 1.
Method 3
If you cannot find .aar files under build/outputs/aar/ directory then type this command in terminal:
gradlew assemble
and after hitting ENTER button you should see the "Build Successful" message on the screen.

Method 4
Try to simply Build > Rebuild project. AAR file should appear in ~/Source/build/outputs/aar
Similar Reads
Different Ways to Format Code in Android Studio
Code formatting is very important when you are building an Android application. This will help you to organize your code properly and to maintain your code to make it easily readable. Below is a list of purposes of having a standard coding format. Purposes of Having Coding Standards A coding standar
3 min read
How to Create a New Fragment in Android Studio?
Android Studio is the official integrated development environment for Google's Android operating system, built on JetBrains' IntelliJ IDEA software and designed specifically for Android development. You can Develop Android App using this. Here, We are going to learn how to create a new Fragment in A
2 min read
Different Ways to Change or Add Themes to Android Studio
When we are working on any editor or IDE we get used to it and its environment like if we are using Sublime then we like its dark background environment. We have now moved to Android studio but we are not comfortable with the default background and theme. Now the point that comes here is how we can
3 min read
Different Ways to Analyze APK Size of an Android App in Android Studio
APK size is one of the most important when we are uploading our app to Google Play. APK size must be considered to be as small as possible so users can visit our app and download our app without wasting so much data. In this article, we will take a look at How we can analyze our APK in Android Studi
3 min read
How to Create Drawable Resource XML File in Android Studio?
Prerequisite: Android Project folder Structure A drawable resource is a common concept for a graphic that can be drawn to the screen and which one can retrieve with APIs such as getDrawable(int) or apply to another XML resource with attributes such as android:drawable and android:icon. There are sev
3 min read
How to Create Different Build Variants in Android?
During the development and release phases of an Android application, we typically require a variety of APKs or different versions of APKs. For example, you may require one debug APK without proguard and one debug APK with proguard, or you may require one APK for free users and one APK for paying use
3 min read
Different Ways to Increase Editor Font Size in Android Studio
Android Studio is the official IDE (Integrated Development Environment) for Android app development and it is based on JetBrainsâ IntelliJ IDEA software. Android Studio provides many excellent features that enhance productivity when building Android apps, such as: A blended environment where one can
2 min read
Different Ways to fix "The APK file does not exist on disk" in Android Studio
Whenever we try to debug the application on Android Studio we encounter the error âThe APK file does not exist on diskâ in the Android Studio. The MainActivity Page throws the error as: The APK file /Users/MyApplicationName/app/build/outputs/apk/app-debug.apk does not exist on disk. So, In this arti
3 min read
Different Ways to Fix "Configuration with name 'default' not found" in Android Studio
Whenever you try to import or clone a code from any version control system, there are chances that Android Studio throws the error: "Error: Configuration with name 'default' not found". There can be more reasons to face this error such as adding .jar files to your android project. So in this article
3 min read
How to Create a Wallpaper App in Android Studio?
Almost all Android devices are having a wallpaper set on their home screen. For setting this wallpaper to the screen many Android devices provides a Wallpaper Application where we can browse different types of wallpapers based on various categories. In this article we will look at, building a simila
15+ min read