Android Studio使用Gradle引入包
方法一
jar包直接复制到lib中右击add as library,等自动构建完成后,打开build.gradle会发现dependencies中多了一个compile file('libs/***.jar');
方法二
新建一个管理包的Module,File->new Module->Android Library。
添加新建的包管理module,Project Structure,选中modules下面的项目,点击Dependencies,点击+号,选择Module Dependency,选择刚才新建的module。
拓展:
新建Android Library的包管理Module之后,Build项目,生成*.arr文件,复制到libs下面
在build.gradle中添加如下代码
android {
repositories{
flatdir{
dirs 'libs'
}
}
}
dependencies {
compile(name:"myadnroidlib",ext:"arr")
}
方法三(推荐)
使用仓库
Project中的build.gradle中配置仓库,使用jcenter仓库
allprojects {
repositories {
jcenter()
}
}
在app的build.gradle中dependendies下输入compile "***",可以到对应工具包的官网中找gradle添加的语句,类似于maven
推荐用法
配置好仓库后,点击Project Structure,选中modules下面的项目,点击Dependencies,点击+号,选择Library Dependency,输入要加入的包
如果这篇文章对你有用,可以关注本人微信公众号获取更多ヽ(^ω^)ノ ~
![微信公众号二维码](https://images.cnblogs.com/cnblogs_com/aeolian/1679458/o_wechat_gzh_qrcode.jpg)