Gradle配置dependencies

转自:http://blog.csdn.net/honjane/article/details/52575803

 dependencies {
        compile fileTree(dir: 'libs', includes: ['*.jar'])
        compile project(':honjane-demo-library')
        betaCompile 'com.squareup.leakcanary:leakcanary-android:1.3.1'
        betaCompile 'com.github.moduth:blockcanary-ui:1.1.4'
        apt 'com.jakewharton:butterknife-compiler:8.1.1'
    }

依赖规则
例如 betaCompile ‘com.github.moduth:blockcanary-ui:1.1.4’

 betaCompile  group: 'com.github.moduth', name: 'blockcanary-ui', version: '1.1.4'  

依赖方式有如下几种
这里写图片描述

Compile
compile是对所有的build type以及favlors都会参与编译并且打包到最终的apk文件中。

Provided
Provided是对所有的build type以及favlors只在编译时使用,类似eclipse中的external-libs,只参与编译,不打包到最终apk。

APK
只会打包到apk文件中,而不参与编译,所以不能再代码中直接调用jar中的类或方法,否则在编译时会报错

下面3种与buildTypes对应的几种依赖

Test compile
Test compile 仅仅是针对单元测试代码的编译编译以及最终打包测试apk时有效,而对正常的debug或者release apk包不起作用。

Debug compile
Debug compile 仅仅针对debug模式的编译和最终的debug apk打包。

Release compile
Release compile 仅仅针对Release 模式的编译和最终的Release apk打包。

依赖本地文件:
compile fileTree

   compile fileTree(dir: 'libs', include: '*.jar')
   provided fileTree(dir: '../honjane-demo-library/libs', include: '*.jar')
   compile(name: 'lib-1.1', ext: 'aar')//依赖并执行本地aar包

依赖远程文件:

  compile "com.jakewharton:butterknife:8.2.1"
  provided 'com.android.support:support-annotations:23.2.1'

依赖库工程(多module):

  compile project(':honjane-demo-library')

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值