2

Trying to migrate to Android Studio 1.3 from good ol' Eclipse but it's frustrating.

How does one add an external library jar to 'External Libraries' section of the project?

enter image description here

Reading SO posts including here, I went to File|Project Structure|Modules selected app and Dependencies tab. Clicked '+'

It brings up the Select Path below How do I add a jar file from D:\mylibs when the Home icon is disabled in the screenshot below?

enter image description here

I tried to copy the jars, and then right-click 'External Libraries' and Paste but it did not work.

Community
  • 1
  • 1
likejudo
  • 3,396
  • 6
  • 52
  • 107
  • 1
    possible duplicate of [How do I add a library project to the Android Studio?](http://stackoverflow.com/questions/16588064/how-do-i-add-a-library-project-to-the-android-studio) – Jared Burrows Jul 31 '15 at 19:15
  • This has been asked a million times. – Jared Burrows Jul 31 '15 at 19:16
  • that is what I tried but it didnt work – likejudo Jul 31 '15 at 19:23
  • Simply copy the JAR file into the `libs` folder, then add `compile files('libs/your_library.jar')` to `dependencies` block of `build.gradle` file of your app –  Jul 31 '15 at 19:32
  • 1
    @yaa110 I tried to copy the jars, and then right-click 'External Libraries' and Paste but it did not work. Should I copy the files into the folder app/libs? I want to add to External Libraries, not to local libs – likejudo Jul 31 '15 at 19:35
  • Yes, you have to copy the jar files into `app/libs` then add `compile files('libs/your_library.jar')` to `dependencies` block of `build.gradle` file of your app. –  Jul 31 '15 at 19:37
  • but that will not add it to the External Libraries folder – likejudo Jul 31 '15 at 19:42
  • @JaredBurrows my question is about 'External Libraries' section of the project and is different. – likejudo Jul 31 '15 at 20:57

3 Answers3

1

There is something wrong with the AS 1.3 dialogue where you add the .jar file. There are no buttons to navigate up the directory tree or change drives. Instead, to add the library, select the .jar file in Explorer (Windows), right click on it, select Copy, go to Android Studio, select Project->[NameOfYourApp]->app->libs and right click on libs and Paste file into it, click Ok on the confirmation box. Then, right click on the .jar file, go toward the bottom of the menu and select Add As Library. Then in the Create Library box confirm that it is adding to app and click Ok. Gradle will then automatically add it to the build dependencies. You can then check the build.gradle file to make sure you see this line: compile files('libs/[filename].jar') under the dependencies section.

Dave Black
  • 65
  • 8
0

Click on your project name on the project explorer, press "F4" or right-click on the name and select "Open Module Settings". Then click on "Dependencies" tab, and click the green "+" button on the right side, then select "File Dependency", this will bring up a Browse Window, use it to open the ".jar" or the ".aar" file.

Ivan Verges
  • 595
  • 3
  • 10
  • 25
0

Follow the next process and you should get it:

Copy The ".jar" File

Open The "app" Folder

Open The "libs" Folder

Past The ".jar" File

Right-Click On "app" And Select "Open Module Settings" Or Press The "F4 Key"

Click On The "Dependencies" Tab

Click On The Green "+" Sign And Select "File Dependency"

Browse The "libs" Folder, Select The ".jar" File And Click On The "OK" Button

Ivan Verges
  • 595
  • 3
  • 10
  • 25