How to add project as a library to Android Studio

Android Development
July 25, 20212 minutesuserVivek Beladiya
How to add project as a library to Android Studio

But if you want to add another project as a library in your application. For that, you need to add that library project to your application as a module dependency.

1. Open Your Project in Android Studio.

2. You will find the two main directory name samples and others.

3. Go to Android Studio and navigate to File -> New -> Import Module -> Select the library path -> Finish.

2021-07-24-60fbb0d6a0a7c

4. Import-Module from Directory.

2021-07-24-60fbb6e95102d

5. Then right-click on the App directory -> Open Module Settings -> Dependencies -> Click on + button inside Declared Dependencies -> Module Dependency -> Select your library -> Ok.

2021-07-24-60fbb90b68dec

2021-07-24-60fbb99dd54e3

Another way to add Module Dependency

  • Open build.gradle Of the main module
dependencies {

implementation project(":sample")

}

There can be a situation when we need to modify the library code according to our requirement then in that case we can follow this method.