一、依赖方式分为三种:jar包依赖(Jar dependency)、本地module依赖(Module dependency)、远程库依赖(Library dependency)。
1、jar包依赖(Jar dependency):compile fileTree(dir: 'libs', include: ['*.jar'])
2、本地module依赖(Module dependency):compile project(':component')
3、远程库依赖(Library dependency):compile 'com.google.code.gson:gson:2.8.5'
二、在Android Studio 3.0以上的环境中,关键字compile被implementation和api代替。
implementation:依赖会隐藏在内部,不对外公开,即如果module A使用implementation依赖了com.google.code.gson:gson:2.8.5,然后module B又将A作为module dependency进行了依赖,那么B是无法直接使用到Gson库的,即在B中无法new出Gson对象。
api:等同于compile,对外公开。
三、jar包存放位置,在与项目module的build.gradle同一级下的libs文件夹下
四、依赖语句位置:在项目module的build.gradle中的dependencies标签中。