码迷,mamicode.com
首页 > 其他好文 > 详细

Gradle 的配置和引用

时间:2019-06-12 15:20:25      阅读:183      评论:0      收藏:0      [点我收藏+]

标签:text   other   java   ansi   layout   class   config   size   active   

我们的Android studio工程有时会存在很多共同的构建包

这里我会新建一个gradle 文件

config.gradle

ext{
    android = [
            applicationId     : "net.huansi.loosecloth",
            compileSdkVersion : 28,
            minSdkVersion     : 15,
            targetSdkVersion  : 28,
            versionCode       : 1,
            versionName       : "1.0",
            support           : "28.0.0"
    ]
    def dependVersion = [
            baseform          : "19.6.6.1-SNAPSHOT",
            retrofit          : "2.2.0",
            okhttp            : "3.6.0",
            dagger2           : "2.7",
            butterknife       : "8.6.0",
            glide             : "4.5.0",
    ]

    var = [
            //base
            appcompat_v7              : "com.android.support:appcompat-v7:${android.support}",
            cardview_v7               : "com.android.support:cardview-v7:${android.support}",
            recyclerview_v7           : "com.android.support:recyclerview-v7:${android.support}",
            design                    : "com.android.support:design:${android.support}",
            rv_adapter_helper         : "com.github.CymChad:BaseRecyclerViewAdapterHelper:2.9.42",
            base_form                 : "baseform.android.huansi.net:baseform:${dependVersion.baseform}",

            //rx
            rxjava                    : "io.reactivex.rxjava2:rxjava:2.2.2",
            rxandroid                 : "io.reactivex.rxjava2:rxandroid:2.0.1",
            rxpermissions             : "com.tbruyelle.rxpermissions2:rxpermissions:0.9.3@aar",

            //network
            gson                      : "com.google.code.gson:gson:2.8.2",
            retrofit                  : "com.squareup.retrofit2:retrofit:${dependVersion.retrofit}",
            retrofit_converter_gson   : "com.squareup.retrofit2:converter-gson:${dependVersion.retrofit}",
            retrofit_adapter_rxjava2  : "com.squareup.retrofit2:adapter-rxjava2:${dependVersion.retrofit}",
            okhttp                    : "com.squareup.okhttp3:okhttp:${dependVersion.okhttp}",
            okhttp_logging_interceptor: "com.squareup.okhttp3:logging-interceptor:${dependVersion.okhttp}",
            glide                     : "com.github.bumptech.glide:glide:${dependVersion.glide}",
            glide_compiler            : "com.github.bumptech.glide:compiler:${dependVersion.glide}",
            glide_transformations     : "jp.wasabeef:glide-transformations:3.0.1",

            //di
            dagger                    : "com.google.dagger:dagger:${dependVersion.dagger2}",
            dagger_compiler           : "com.google.dagger:dagger-compiler:${dependVersion.dagger2}",
            butterknife               : "com.jakewharton:butterknife:${dependVersion.butterknife}",
            butterknife_compiler      : "com.jakewharton:butterknife-compiler:${dependVersion.butterknife}",

            //other
            multidex                  : "com.android.support:multidex:1.0.3",
            smart_refresh             : "com.scwang.smartrefresh:SmartRefreshLayout:1.0.5.1",
            //滑动轮
            wheelview                 : "com.contrarywind:wheelview:4.0.5",
            //相册选择
            picture_selector          : "com.github.LuckSiege.PictureSelector:picture_library:v2.2.0",
            //dialog管理
            material_dialog           : "com.afollestad.material-dialogs:core:0.9.6.0",

            constraint                : "com.android.support.constraint:constraint-layout:1.1.3",
            autofittextview           : "me.grantland:autofittextview:0.2.1"
    ]

}

然后在工程的build.gradle中引用

技术图片

技术图片

apply from :"config.gradle"

 

应用到各个module中引用

技术图片

 

Gradle 的配置和引用

标签:text   other   java   ansi   layout   class   config   size   active   

原文地址:https://www.cnblogs.com/woaixingxing/p/11009704.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!