Android Studio 1.0.1 add external libraries

[亡魂溺海] 提交于 2019-12-30 04:02:07

问题


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

and when i see it in the explorer there is a empty libs folder

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:

so sorry that admins stopping the question without understanding it.


回答1:


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




回答2:


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')
}


来源:https://stackoverflow.com/questions/27541783/android-studio-1-0-1-add-external-libraries

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!