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
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.
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.
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.
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.
From Android Studio package manager select project:
Then make a new directory in project level named libs
Now right click the libs and select Reveal in finder and then paste here your .aar file.
Now in Build.gradle(Module) add the following implementation.
implementation files('../libs/testaarfile.aar')
and snyc your project.
For Android Studio Bumblebee | 2021.1.1 Patch 3
I have followed steps suggested by the Android developer site:
Copy .aar file into the libs folder of the app
File -> Project Structure... -> Dependencies
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With