今天在做项目时,需要导入一个第三方类库,自己也查找了网上的一些资料,现在把这个过程总结一下。
1、将开源库(我的是library)下载下来,放置在你的项目中与 app 目录同级的目录下,然后编辑 setting.gradle 文件,加入:”:开源库文件夹名”。
include ':app',':library'2、 然后再回到你的 app 目录下的 build.gradle 文件(注意:是app目录下的build.gradle 文件,因为在这里有三个build.gradle 文件,分别在app目录下,library目录下,项目目录下,我第一次就加错地方了),在 dependencies { }节点下加入:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:21.0.3'
compile project(':library')
}
3、根据相应提示修改library下的build.gradle 文件,主要是sdk版本和gradle版本等。