Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

importing an existing JAR or AAR as new project module

how to import JAR or AAR package as new project module in A new Android Studio Arctic Fox | 2020.3.1 Canary 9 ?

please let me know.

like image 486
Didier Supernover Avatar asked Mar 12 '21 10:03

Didier Supernover


People also ask

How do I import classes from AAR?

The process for that is as follows, press the right mouse key on one of your existing modules and select select "open module settings" then press the "+" sign to add a new module choose import jar/aar and select the relevant file that was generated in section 1. Let me know if it's working for you.


Video Answer


4 Answers

This works on Android Studio Arctic Fox Beta 02

Step 1 : Navigate to, File -> Project Structure. You can also press Ctrl+Alt+Shift+S

You will see a window just like below.

enter image description here

Step 2 : Click On app module as shown in image

Step 3 : Click on + icon as marked in image

enter image description here

Step 4 : You will see option to select jar/aar dependency. Click on it

enter image description here

You will see another window just like above asking you to specify path. Specify the path in which you kept the aar/jar file and hit Ok.

That should work

like image 189
AgentP Avatar answered Oct 13 '22 01:10

AgentP


Step 1: Put your aar file in the libs folder. And let’s take the file name is supernover.aar as an example.

Step 2: Put the following code in your Project level

build.gradle  file,
    allprojects {
   repositories {
      jcenter()
      flatDir {
        dirs 'libs'
      }
   }
}

and in the app level module write the below code,

dependencies {
    Implementation(name:'supernover', ext:'aar')
}

Step 3: Then Click sync project with Gradle files.

If everything is working fine, then you will see library entry is made in build ->intermediates -> exploded-aar.

like image 28
Didier Supernover Avatar answered Oct 13 '22 01:10

Didier Supernover


For Android Studio Bumblebee, original answer given here

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 2
SANAT Avatar answered Oct 12 '22 23:10

SANAT


You can directly implement using JAR/ARR file path.

implementation files('/File Path/file.aar')
like image 1
Tushar Lathiya Avatar answered Oct 12 '22 23:10

Tushar Lathiya