compile 大家都很熟悉
provided 仅在编译时使用,但最终不会被编译到apk或aar里
具体总结参考如下(转自https://blog.csdn.net/w958796636/article/details/52919582)
方式:1:它就会自动把这个包下载下来,并且引用它。节省git空间,而且修改版本也很方便。
compile \'com.android.support:support-v4:23.3.0\'
方式2:引用libs下所有jar包
compile fileTree(dir: \'libs\', include: [\'*.jar\'])
方式3:引用一个jar
compile files(\'libs/fastjson-1.1.53.android.jar\')
方式4:引用一个aar文件,注意并不能像 方式2 那样自动引用全部的aar,而需要对每个aar分别进行引用。
compile(name: \'aar_file_name\', ext: \'aar\')
方式5:引用库类型的项目
compile project(\':xxxsdk\')
方式6:仅仅在编译时使用,但最终不会被编译到apk或aar里
provided files(\'libs/glide-3.7.0.jar\')
补充一点
在Gradle4.1之后
使用implementation替代compile,有别于compile的是并不能跨模块依赖。保证封装隐蔽性。
使用compileOnly 替代 provided,用法一致
继续阅读与本文标签相同的文章
-
Python快递鸟API接口对接(即时查询|物流跟踪|电子面单|单号识别)
2026-05-18栏目: 教程
-
免费物流快递单号查询API接口及使用教程
2026-05-18栏目: 教程
-
【译】Hadoop发生了什么?我们该如何做?
2026-05-18栏目: 教程
-
阿里云上云企业案例周刊·第2期
2026-05-18栏目: 教程
-
虚拟机模拟部署Extended Clusters(一)基础环境准备
2026-05-18栏目: 教程
