importing jar libraries into android-studio

Try this…

  1. Create libs folder under the application folder.
  2. Add .jar files to libs folder.
  3. Then add .jar files to app’s build.gradle dependency.
  4. Finally Sync project with Gradle files.

1.Create libs folder:

enter image description here

2.Add .jar to libs folder:

enter image description here

3.Edit app’s build.gradle dependency:

  • Open app/build.gradle

enter image description here

4.Sync project with Gradle files:

  • Finally add .jar files to your application.

enter image description here

UPDATE:

Here I’m going to import org.eclipse.paho.client.mqttv3.jar file to our app module.

  1. Copy your jar file and paste it in directory called libs.

open project structure

  1. Press Ctrl + Alt + Shift + s or just click project structure icon on the toolbar.

project structure

  1. Then select your module to import .jar file, then select dependencies tab.

add jar

  1. Click plus icon then select File dependency

File dependency

  1. Select .jar file path, click OK to build gradle.

jar path

  1. Finally we’re imported .jar file to our module.

imported jar file

Leave a Comment