Android Studio 1.0.1 add external libraries
Asked Answered
S

2

12

I have just downloaded Android Studio 1.0.1 and this is the new project structure

enter image description here

and when i see it in the explorer there is a empty libs folder enter image description here

i want to import 3 external libraries i have, which i want to use.

build.gradle has already defined this

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
}

but when i copy my libraries in libs folder my project still dont recognize it, how do i make use of the libs folder and copy my libraries in this folders and use it? any help?

Edit: it was a simple question, how to add libraries to project in Android Studio like we do in eclipse, for eg i have a library project(a folder, not a jar!). in my case i have a library project 'viewPagerIndicator' (again a Library folder, not a jar!) i have to add it to my project like i use to do it with eclipse by importing project, right click->properties->android->Library->add-> select the library project

PS: i have found the answer now. suppose my library project name is 'viewPagerIndicator' - Copy library project on root of my Android Studio Project - Under build.gradle(under your Android Studio Project folder) write this under dependencies compile project(':viewPagerIndicator') - include it in settings.gradle, write: include ':viewPagerIndicator' - Sync project with gradle files

this is how project structure look like now:

enter image description here

so sorry that admins stopping the question without understanding it.

Stivers answered 18/12, 2014 at 8:5 Comment(2)
do you want to add .jar ?Sheepshanks
I did as you had instructed. But I end up with this error Error:Configuration with name 'default' not found.Leffen
S
23

First you have to add library project (module) in Android Studio

File -> Import Module

To add library project (module) in build path, click

File -> Project Structure

On the left hand side click on

app -> Dependencies tab -> green + button -> Module dependency

Now select the library project you already added.

For more details refer this link

Sheepshanks answered 18/12, 2014 at 8:27 Comment(1)
My project correpted thanks :) Error:(64, 0) No such property: sonatypeUsername for class: org.gradle.api.internal.project.DefaultProject_Decorated <a href="openFile">Open File</a>Uniseptate
A
1

In My Case to add external library project into android studio 1.1.0

step-1 : File -> Import Module -> set path for library project

step-2 : Set dependencies{} in main projects's build.gradle like,

dependencies {
    compile project(':facebookSDK')
    compile project(':slidingMenu')
    compile project(':SkyconsLibrary')
}
Ailurophile answered 12/5, 2015 at 10:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.