Android Studio 1.0.1 添加外部库 [英] Android Studio 1.0.1 add external libraries

查看:38
本文介绍了Android Studio 1.0.1 添加外部库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚下载了 Android Studio 1.0.1,这是新的项目结构

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

当我在资源管理器中看到它时,有一个空的 libs 文件夹

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

我想导入我想要使用的 3 个外部库.

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

build.gradle 已经定义了这个

build.gradle has already defined this

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

但是当我将库复制到 libs 文件夹中时,我的项目仍然无法识别它,我如何使用 libs 文件夹并将我的库复制到此文件夹中并使用它?有什么帮助吗?

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?

这是一个简单的问题,如何在 Android Studio 中向项目添加库就像我们在 Eclipse 中所做的那样,例如我有一个库项目(一个文件夹,而不是一个 jar!).在我的情况下,我有一个库项目viewPagerIndicator"(再次是一个库文件夹,而不是一个 jar!)我必须将它添加到我的项目中,就像我以前通过导入项目使用 Eclipse 一样,右键单击 -> 属性 -> android->库->添加->选择库项目

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:我现在找到了答案.假设我的库项目名称是viewPagerIndicator"- 在我的 Android Studio 项目的根目录上复制库项目- 在 build.gradle 下(在你的 Android Studio 项目文件夹下)在依赖项下写这个编译项目(':viewPagerIndicator')- 将其包含在 settings.gradle 中,写入:包括':viewPagerIndicator'- 将项目与 gradle 文件同步

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.

推荐答案

首先你得在Android Studio中添加库项目(模块)

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

在左侧点击

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

现在选择您已经添加的库项目.

Now select the library project you already added.

有关详细信息,请参阅此链接

这篇关于Android Studio 1.0.1 添加外部库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆