dependencies闭包的整体功能是指定当前项目所有依赖关系:本地依赖、库依赖及远程依赖。
本地依赖:可以对本地Jar包或者目录添加依赖关系
库依赖:可以对项目中的库模块添加依赖关系
远程依赖:可以对jcenter库上的开源项目添加依赖,标准的远程依赖格式是:域名:组织名:版本号
dependencies { 181 implementation fileTree(dir: 'libs', include: ['*.jar']) // 本地依赖 182 // 远程依赖,com.android.support是域名部分,appcompat-v7是组名称,26.1.0是版本号 183 implementation 'com.android.support:appcompat-v7:26.1.0' 184 implementation 'com.android.support.constraint:constraint-layout:1.0.2' 185 implementation project(':hello') // 库依赖 186 testImplementation 'junit:junit:4.12' // 声明测试用列库 187 androidTestImplementation 'com.android.support.test:runner:1.0.1' 188 androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1' 189 }
参考博客:
https://www.cnblogs.com/steffen/p/9212765.html
https://docs.gradle.org/current/userguide/declaring_dependencies.html