I want to add external library https://github.com/foursquare/foursquare-android-oauth to my Android application (I use Android Studio, the instructions provided by lib autho
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
Now you can start using the library in your project.
SIMPLE STEPS TO ADD ANY LIBRARY IN ANDROID STUDIO:
Copy the file in question from any folder in your computer (eg. C:/documents/xyz.jar"), then go to Android Studio and right-click the Project Library folder and select paste.
Now, right click on the newly added Library file and select the option "add as Library"
D.O.N.E
To reference an external lib project without copy, just do this:
- Insert this 2 lines on setting.gradle
:
include ':your-lib-name'
project(':your-lib-name').projectDir = new File('/path-to-your-lib/your-lib-name)
Insert this line on on dependencies part of build.gradle
file:
compile project(':your-lib-name')
Sync project
Any other way to import this lib? I can simply copy-paste source code into my source or create JAR out of it?
Complete Steps for importing a library in Android Studio 1.1
Add the following line with your module name
compile project(':internal_project_name')
Taken from: how to add library in Android Studio
1.Goto File -> New -> Import Module
2.Source Directory -> Browse the project path.
3.Specify the Module Name – it is used for internal project reference.
Open build.gradle (Module:app) file.
implementation project(':library')
Three ways in android studio for adding a external library.
if you want to add libarary project dependency in your project :
A. In file menu click new and choose import module choose your library project path and click ok, library project automatically add in your android studio project .
B. Now open your main module(like app) gradle file and add project dependency in dependency section dependencies {
compile project(':library project name')
if you want to add jar file : A. add jar file in libs folder. B. And Add dependency
compile fileTree(dir: 'libs', include: '*.jar') // add all jar file from libs folder, if you want to add particular jar from libs add below dependency.
compile files('libs/abc.jar')
Add Dependency from url (recommended). like
compile 'com.mcxiaoke.volley:library-aar:1.0.0'