Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add a jar in External Libraries in Android Studio?

People also ask

How do I create a JAR file with an external library?

You can right-click on the project, click on export, type 'jar', choose 'Runnable JAR File Export'. There you have the option 'Extract required libraries into generated JAR'.


A late answer, although I thought of giving an in-depth answer to this question. This method is suitable for Android Studio 1.0.0 and above.


STEPS


  1. First switch your folder structure from Android to Project.

enter image description here

  1. Now search for the libs folder inside the app folder.

enter image description here

  1. Once you have pasted the .jar file inside libs folder. Right click on the jar file and at end click on Add as library. This will take care of adding compile files('libs/library_name.jar') in build.gradle [You don't have to manually enter this in your build file].

enter image description here

Now you can start using the library in your project.


Add your jar file to the folder app/libs. Then right click the jar file and click "add as library".

If there is no libs folder you can create it. Click on the combo box that says "Android", and change it to "Project"

enter image description here

From here, you can right click on "apps" in the directory tree and go to "New" => "Directory"


Put your JAR in app/libs, and in app/build.gradle add in the dependencies section:

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

Create "libs" folder in app directory copy your jar file in libs folder right click on your jar file in Android Studio and Add As library... Then open build.gradle and add this:

dependencies {
    implementation files('libs/your jar file.jar')
}

Step 1: Download any JAR file for your Project.enter image description here

Step 2: Copy .jar file and past in libs folder.

enter image description here enter image description here

Step 3: Click on File > Project Structure >Select app > Dependencies

enter image description here

Step 4:

enter image description here

Step 5:

enter image description here

Step 6: After click Ok button then we can see the Dependencies add like this way:

enter image description here