Adding external library (.jar) in Android Studio
I ran the gradlew.bat file, which gave me the following Exception:
Exception in thread "main" java.lang.RuntimeException: Could not determine wrapper version.at
org.gradle.wrapper.GradleWrapperMain.wrapperVersion(GradleWrapperMain.java:111)at
org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61)Caused by:
java.lang.RuntimeException: No build receipt resource found.at
org.gradle.wrapper.GradleWrapperMain.wrapperVersion(GradleWrapperMain.java:97)... 1 more
which brought me to this answer and indeed i had used an !
in my project name. Removing it somehow solved the problem.
Android Studio - Importing external Library/Jar
So,
Steps to follow in order to import a JAR sucesfully to your project using Android Studio 0.1.1:
- Download the library.jar file and copy it to your /libs/ folder inside your application project.
- Open the build.gradle file and edit your dependencies to include the new .jar file:
compile files('libs/android-support-v4.jar', 'libs/GoogleAdMobAdsSdk-6.4.1.jar')
- File -> Close Project
- Open a command prompt on your project's root location, i.e
'C:\Users\Username\AndroidStudioProjects\MyApplicationProject\'
- On the command prompt, type
gradlew clean
, wait till it's done. - Reopen your application project in Android Studio.
- Test run your application and it should work succesfully.
Adding external library in Android studio
Try this:
File > Project Structure > Dependencies Tab > Add module dependency (scope = compile
)
Where the module dependency is the project library Android folder.
importing jar libraries into android-studio
Updated answer for Android Studio 2
The easy and correct way to import a jar/aar into your project is to import it as a module.
New
-> Module
Select Import .JAR/.AAR
Package
Select the .JAR/.AAR file and put a module name
Add the module as a dependency
Add external library and jar in Android Studio
For adding external library or dependency, you can either edit gradle
file for app manually, or you can do it by Project Structure
.
- Edit
Gradle
File of app
Open gradle file of app, you can add/edit in the dependencies
tag,
the first line compile fileTree(dir: 'libs', include: ['*.jar'])
indicates that it will include the jar files in this project;
- in
Project Structure
File
-> Project Structure
, and in the pop-up window, click app
in the left list, then click dependencies
, in the top-right corner, click +
to add new dependency.
Related Topics
Dialog to Pick Image from Gallery or from Camera
Install_Failed_Update_Incompatible When I Try to Install Compiled .Apk on Device
How to Change the Default Icon on the Searchview, to Be Use in the Action Bar on Android
How to Implement Getfilter() with Custom Adapter That Extends Baseadapter
How to Make Gradient Background in Android
Android Studio How to Package Single Aar from Multiple Library Projects
How to Get the Screensize Programmatically in Android
Error: "Adb Connection Error:An Existing Connection Was Forcibly Closed by the Remote Host"
Overflow Auto Doesn't Work in Android Browser
Android Failed to Load Js Bundle
How to Display Custom View in Actionbar
Android How to Display 2 Listviews in One Activity One After the Other
Execution Failed for Task 'App:Mergedebugresources' Crunching Cruncher....Png Failed
Install an APK File from Command Prompt
Adt 22.2 New App Wizard: Unsupported Template Dependency: Upgrade Your Android Eclipse Plugin