Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add JAR in Android Studio 1.0 [duplicate]

I want to add an external library to my Android Studio 1.0 project. The other answers at stackoverflow seem to be outdated. At least I can't find a "lib" folder in my project and don't know how to create one.

edit: As I was pointing out I am referring to the latest version of Android Studio. I assume there are some differences between this version and the one referred to. The shortcuts are not working and my folder structor varies a lot. I created a new HelloWorld project to verify it.

like image 942
user1255102 Avatar asked Dec 18 '14 15:12

user1255102


People also ask

What is the difference between AAR and jar?

Unlike JAR files, AAR files offer the following functionality for Android applications: AAR files can contain Android resources and a manifest file, which allows you to bundle in shared resources like layouts and drawables in addition to Java classes and methods.

How to add dependency in Android?

Go to File > Project Structure in Android Studio. Select the app module in the Modules list on the left. Select the Dependencies tab. Click the + button on the lower left to add the dependency.

How to add library dependency in Android Studio?

Right click on the app folder -> Open Module settings -> go to the dependencies tab -> Click on the '+' button -> click on Module Dependency. The library module will be then added to the project's dependencies.

Where is the jar file in Android Studio?

If you are unable to find the libs folder in Android studio then open your android project in “Project” mode If the project is already opened in the “Android” mode. Then go to Your Project Name > app > libs and right-click on it and paste the downloaded JAR files.


1 Answers

In the module that want to use the jar, create a lib folder and place your jar in it.

In the module build.gradle file, add this in the dependencies group:

compile files('lib/my_jar.jar')
like image 141
Gaëtan Avatar answered Sep 23 '22 08:09

Gaëtan