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,用法一致
 

收藏 打印