Home > Enterprise >  How do I add an external library (Apache Commons Lang) to an Android Studio app manually?
How do I add an external library (Apache Commons Lang) to an Android Studio app manually?

Time:04-07

I know how to work with Apache Commons Lang 3 library in an Android Studio app by implementing it in the build.gradle file using implementation 'org.apache.commons:commons-lang3:3.12.0'. But I want to know if it's possible to include the Apache Commons Lang 3 library (or for that matter, any external library) in the Android app manually if I have the library downloaded on my PC? For example, like adding the .jar file of the library to Android Studio or something of that sort.

I'm asking from the viewpoint where I have a library folder in my PC which doesn't have an online link from which gradle can download and merge it with the Android Studio app automatically. How do I add that library to my Android app? Any elucidation on this matter is complimented.

Regards

CodePudding user response:

These are the steps to add a local library as dependency (.jar):

  • put the jar file into "libs" folder
  • add the following line to your build.gradle, inside dependencies:

compile fileTree(dir: 'libs', include: ['*.jar'])

like:

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

CodePudding user response:

I found two good links describing how to achieve the objective I mentioned:

  • Related