gradle android的依赖配置dependencies

/**
 * 配置仓库
 */
repositories{
    //本地扁平目录仓库
    flatDir{
        dir('libs')
    }

    jcenter()
}

/**
 * 自定义dependencies过滤组
 * 因为dependencies只支持基本的风味分组 比如free x86 arm等 不支持组合
 * 这样定义后就支持组合了
 */
configurations{
    freeArmDebugCompile{}
}

/**
 *  调用./gradlew :app:dependencies 查看依赖的情况
 *
 * compile 编译(classpatch)+打包apk
 * apk 仅打包 不参与编译
 * provided 只编译 不打包
 */
dependencies {
    freeArmDebugCompile 'pub.devrel:easypermissions:0.1.9'
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:25.3.1'
    testCompile 'junit:junit:4.12'


    //引进目录下的所有.jar文件
    compile fileTree(include: ['*.jar'], dir: 'libs')

    //引进指定的jar包 目录相对于build.gradle
//    compile files('libs/a.jar','libs/b.jar')

    //导入myLibrary库 并指定配置为release 配和下面补充的第二条  ,
    compile project(path:':mylibrary',configuration:'release')



    //下面是多种写法 出现重复的时候会自动选择最新的依赖,排除重复依赖
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    //另外一种写法
    compile group:'com.android.support.constraint',name: 'constraint-layout',version: '1.0.2'
    //使用1开头的最高版本
    compile group: 'com.android.support.constraint',name: 'constraint-layout',version: '1.+'
    //使用最新版本
    compile group: 'com.android.support.constraint',name:'constraint-layout',version:'latest.integration'

    compile 'com.android.support:appcompat-v7:25.3.1'
    compile 'com.facebook.fresco:fresco:0.14.0',{
        //关闭fresco传递的一些依赖 这样会把所有的传递依赖都关闭
//        transitive false
        //关闭指定的传递依赖 可以解决依赖冲突
        exclude(group:'com.android.support',module:'support-core-utils')
    }

    //配置本地扁平仓库support-test-aa.arr 前提必须配置repositories
    //不建议这么配置 容易缺少依赖 最好配置远程仓库 远程仓库含有pom文件 可以指定依赖
//    compile name:'support-test-aa',ext:'aar'

}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值