0

I was trying to include .AAR file in my project as a module. So, that I can keep my project code as a modular, I tried my solution which is given on stack overflow, but nothing work the way I required. Finally I found a way to add in the project with best way.

BAIJU SHARMA
  • 276
  • 4
  • 9

1 Answers1

2
This is tested and working fine in my project. Android studio ver 4.4.

Click File -> New Module -> Select Android Library.
Added Module name -(Of your choice)
Package name - (Of your choice)
Language - Java/Kotlin
Bytecode Level -8 
Min SDK support - (Of your choice)
Click **Finish**.

A module will be created in your project. This module will have a libs folder. Paste your .AAR file inside the lib folder.

At project level gradle add below code.

allprojects {
    repositories {
        google()
        jcenter()

        ***flatDir{
            dirs 'libs'
        }***

        maven { url 'https://www.jitpack.io' }
    }
}

Sync your Gradle file.

Now, go to your module level gradle file add below code.

dependencies {
    **implementation fileTree(dir: 'libs', include: ['*.aar'])**
}

Add below code in the project level gradle.

dependencies {
        implementation project(': your module name')
    }

Sync your Gradle file.

That's it. Note: It is the best way to import .AAR file in the project.

BAIJU SHARMA
  • 276
  • 4
  • 9