AndroidStudio Gradle dependencies依赖方式

Url依赖

implementation 'com.github.bumptech.glide:glide:4.12.0'


Jar依赖

implementation files('libs/glide-4.3.1.jar')
implementation files('libs/glide_annotations-4.3.1.jar')
implementation files('libs/glide_disklrucache-4.3.1.jar')
implementation files('libs/glide_gifdecoder-4.3.1.jar')'


AAR依赖(library直接使用aar依赖会有问题,后面说)

repositories{

    flatDir{

        dirs 'libs'
    }
}

dependencies {

    implementation(name: 'appcompat-v7-25.3.1', ext: 'aar')
}

Project依赖

implementation project(':base_lib_moudle')


批量依赖(依赖libs文件夹下面的所有jar)

implementation fileTree(dir: 'libs', include: ['*.jar'])
//依赖libs文件夹下所有jar,但是不包括framework.jar
implementation fileTree(dir: 'libs',excludes: ["framework.jar"], include: ['*.jar'])


批量依赖(依赖libs文件夹下面的所有aar)

implementation fileTree(dir: 'libs', include: ['*.aar'])
//依赖libs文件夹下所有aar,但是不包括 utilcode-1.9.9.aar
implementation fileTree(dir: 'libs',excludes: ["utilcode-1.9.9.aar"], include: ['*.aar'])


Url依赖移除指定依赖

debugApi ('com.squareup.leakcanary:leakcanary-android:2.7'){

   exclude group: 'com.squareup.okio', module: 'okio'

}

transitive依赖
transitive dependencies 被称为依赖的依赖,称为“间接依赖”比较合适。
在后面加上@aar,意指你只是下载该aar包,而并不下载该aar包所依赖的其他库,那如果想在使用@aar的前提下还能下载其依赖库,则需要添加transitive=true的条件。

implementation ('com.alibaba.android:vlayout:1.2.1@aar') {

    transitive = true
}

implementation api compileOnly 的区别
implementation : 依赖但不穿透(比如:A implementation B,B implementation C,此时A调用不了C的类和方法)
api 依赖并且穿透(比如:A api B,B api C,此时A可以调用C的类和方法)
compileOnly 仅参与编译(打包时,不打入APK文件中,)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值