How to Import External Jars to Android Studio Project


To import an external .jar file in your Android Studio Project, just follow the below steps,

  1. Move from Android view to Projects view

  2. Now under app folder you should see libs, if you don't see it, create it
  3. Drag & Drop the .jar file here, you maybe get a prompt "This file does not belong to the project", just click OK
  4. Now you should see the jar file under libs folder, right-click on the jar file and select "Add as Library", Click OK for prompt "Create Library"
  5. That's it!! Now, this jar has been added.

?? We do not need to add the dependency in build.gradle manually unlike previous versions of Android Studio. But to verify, just move to the Android Project View again and check Gradle Scripts -> build.gradle , you should be able to see the jar added under dependencies, nineoldandroids-2.2.0.jar is the jar that I have added.

Gradle example importing jars in Android Studio:
dependencies {
   compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:21.0.3'
    compile files('libs/nineoldandroids-2.2.0.jar')
}

⚡️ Note that the process to add an external Project Folder to an Android Studio Project is not the same.

add to library
add to library


















Copyright © Code2care 2024 | Privacy Policy | About Us | Contact Us | Sitemap