Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to import .AAR module on Android Studio 4.2

Previously I used File > New > New Module > Import .JAR/.AAR Package

but the option to Import .JAR/.AAR Package from the New Module wizard has been removed on Android Studio 4.2 and following the document which suggests using the Project Structure Dialog reveals no clear answer for importing .AAR module and seems to be outdated

I tried adding the module as a dependency in the project Structure but it did not work

like image 808
husain_byk Avatar asked May 27 '21 14:05

husain_byk


People also ask

What is .AAR file in Android Studio?

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.

How to generate AAR file in Android Studio?

Step1: Start the Android Studio and open the project where you want to generate the AAR file. Step2: Click the Gradle option in 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.

How to add AAR file to a Gradle project?

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. Step9: “ Sync the project” and wait for the build successful.

How to implement library module in Android Studio?

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 on that ( Click here ). Step1: Start the Android Studio and open the project where you want to generate the AAR file.


Video Answer


2 Answers

From Android Studio package manager select project:

enter image description here

Then make a new directory in project level named libs

enter image description here

enter image description here

Now right click the libs and select Reveal in finder and then paste here your .aar file.

enter image description here enter image description here

Now in Build.gradle(Module) add the following implementation.

implementation files('../libs/testaarfile.aar') 

and snyc your project.

like image 152
Hafiza Avatar answered Oct 17 '22 14:10

Hafiza


For Android Studio Bumblebee | 2021.1.1 Patch 3

I have followed steps suggested by the Android developer site:

  1. Copy .aar file into the libs folder of the app

  2. File -> Project Structure... -> Dependencies

enter image description here

  1. Click on "+" icon and select JR/AAR Dependency and select app module

enter image description here

  1. Add .aar file path in step 1.

enter image description here

  1. Check your app’s build.gradle file to confirm a declaration.
like image 4
SANAT Avatar answered Oct 17 '22 13:10

SANAT