I am new to Android Studio. What I need to do is add a few jar files in the External Libraries
below the < JDK > folder.
This is how you can add .jar
file in Android Studio 2.1.3.
Copy the .jar file
paste the file in Libs folder and then right click on .jar file and press Add as library
open build.gradle
add lines under dependencies as shown in screenshot
Now press play button and you are done adding .jar file
Put your JAR in app/libs, and in app/build.gradle add in the dependencies
section:
compile fileTree(dir: 'libs', include: ['*.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
Now you can start using the library in your project.
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')
}
Example with Parse jar...
Add jars to libs folder from Project view … create lib folder if not exists
Copy all jars there...
Add libs to gradle.... in build.gradle file :
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.0.0'
compile 'com.android.support:design:23.0.0'
compile 'com.android.support:percent:23.0.0'
compile 'com.parse.bolts:bolts-android:1.+'
compile fileTree(dir: 'libs', include: 'Parse-*.jar’)
}
For add all jars of lib folder... change Parse-*.jar to *.jar
The "official way" to add a jar into your android project as an external library, is to add the jar in dependencies { } section in build.gradle.
If you've done all of the above, and none of the above works, then there are two other possibilities:
package a.b.c;
should be matching to folder a > folder b > folder c.However, if you are going with cordova, here are some tips of adding external jars.
"build-extras.gradle" is the better way to manage your gradle file.
Here are the steps to manage extra settings in cordova-based android project:
//Other settings go here, e.g.: buildscript { ... } ext.postBuildExtras = { // you may have some other settings, e.g.: android { ... } dependencies { compile files('libs/abc.jar') } }
(More detailed steps here: Extending the cordova gradle file to include google services )
cordova build android