Android Studio–Add local jar / library to project

sapan
Hi recently I want to add third party module to my project. However I want don’t to use that slow gradle to download it. I downloaded the required jars. Now I had to import it to my project.

I tried method #1
Right Click project –>New –> Module –> Import .JAR/.AAR project-> Select my library and finish. However this still didn’t work for me.



Method #2 
this worked !
image
  • Change my project view from “android” to “Project”
  • Create “libs” folder.
  • Copied my .jar to this folder.
  • Right click the added .JAR and select “Add Library”.
  • Check your build.gradle below lines will be present
  • compile files('libs/android-async-http-1.4.9.jar')

#Method 3

To add any imported library project to the current application. Open build.gradle and add line

compile project(path: ':projectname')

like:

dependencies {
 compile fileTree(dir: 'libs', include: ['*.jar'])
 compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:support-v4:23.4.0'
compile 'com.android.support:support-vector-drawable:23.4.0'
testCompile 'junit:junit:4.12'
compile project(path: ':projectname') 
}

Post a Comment

0Comments
Post a Comment (0)

#buttons=(Accept !) #days=(20)

Our website uses cookies to enhance your experience. Learn More
Accept !