美文网首页
android studio配置config.gradle统一管

android studio配置config.gradle统一管

作者: 番茄焖西红柿 | 来源:发表于2020-05-12 09:42 被阅读0次
    在工程的根目录下新建一个 config.gradle文件
    ext {
        android = [
                compileSdkVersion: 28,
                buildToolsVersion: '28.0.2',
                minSdkVersion    : 19,
                targetSdkVersion : 28,
                applicationId    : "xxx.xxx.xxx",
                versionCode      : 1,
                versionName      : "1.0.0",
        ]
    
        //version 版本控制
        versions = [
    
        ]
    
        //androidx支持库配置
        androidx = [
                "androidx-appcompat"          : "androidx.appcompat:appcompat:1.0.2",
                "androidx.lifecycle"          : "androidx.lifecycle:lifecycle-extensions:2.1.0",
                "androidx.recyclerview"       : "androidx.recyclerview:recyclerview:1.1.0",
                "androidx.constraintlayout"   : "androidx.constraintlayout:constraintlayout:1.1.3",
                "androidx.cardview"           : "androidx.cardview:cardview:1.0.0",
                "android.material"            : "com.google.android.material:material:1.0.0",
                "androidx.navigation-fragment": "androidx.navigation:navigation-fragment:2.1.0",
                "androidx.navigation-ui:"     : "androidx.navigation:navigation-ui:2.1.0",
        ]
    
        //依赖第三方配置
        dependencies = [
                "butterknife"                  : "com.jakewharton:butterknife:7.0.1",//
                "gson"                         : "com.google.code.gson:gson:2.8.5",//json解析
                "rxjava"                       : "io.reactivex.rxjava2:rxjava:2.1.3",
                "rxandroid"                    : "io.reactivex.rxjava2:rxandroid:2.0.1",
    
                /******************************网络配置  --S*****************************************/
                "converter-gson"               : "com.squareup.retrofit2:converter-gson:2.1.0",
                "converter-scalars"            : "com.squareup.retrofit2:converter-scalars:2.0.0",
                "retrofit"                     : "com.squareup.retrofit2:retrofit:2.2.0",
                "adapter-rxjava2"              : "com.squareup.retrofit2:adapter-rxjava2:2.2.0",
                "logging-interceptor"          : "com.squareup.okhttp3:logging-interceptor:3.5.0",
                /******************************网络配置  --E*****************************************/
    
                "rxpermissions"                : "com.tbruyelle.rxpermissions2:rxpermissions:0.9.3@aar",//权限申请
                "glide"                        : "com.github.bumptech.glide:glide:3.7.0",//google图片加载器
                "BaseRecyclerViewAdapterHelper": "com.github.CymChad:BaseRecyclerViewAdapterHelper:2.9.30",//万能适配器
                "eventbus"                     : "org.greenrobot:eventbus:3.1.1",//事件总线
                "wechat"                       : "com.tencent.mm.opensdk:wechat-sdk-android-with-mta:1.1.6",//微信支付
                "PinnedSectionItemDecoration"  : "com.oushangfeng:PinnedSectionItemDecoration:1.3.2",//
                "greendao"                     : "org.greenrobot:greendao:3.2.0",//数据库
                "roundedimageview"             : "com.makeramen:roundedimageview:2.1.1",//圆角图片
                "circleimageview"              : "de.hdodenhof:circleimageview:2.0.0",//圆形图片
                "numberprogressbar"            : "com.daimajia.numberprogressbar:library:1.4@aar",//进度条
                "zxing"                        : "cn.bingoogolapple:bga-qrcode-zxing:1.3.6",//二维码
                "PersistentCookieJar"          : "com.github.franmontiel:PersistentCookieJar:v1.0.1",//网络请求cookie管理
                "link_builder"                 : "com.klinkerapps:link_builder:2.0.4",//
                "jpush"                        : "cn.jiguang.sdk:jpush:3.3.4",//极光推送
                "jcore"                        : "cn.jiguang.sdk:jcore:2.1.2",//极光推送
                "aliyun-oss"                   : "com.aliyun.dpa:oss-android-sdk:+",//阿里云图片上传
                "Luban"                        : "top.zibin:Luban:1.1.8",//图片压缩
                "jwtdecode"                    : "com.auth0.android:jwtdecode:1.1.1",//jwt token解析
    
        ]
    
    }
    
    在android studio的Project根目录下的build.gradle文件中引入我们创建的配置文件
        apply from:'config.gradle'//引入我们创建的配置文件
        buildscript {
            repositories {
                jcenter()
              }
            ......
         }
    
        allprojects {
            repositories {
                jcenter()
            }
        }
    
    在app的build.gradle中添加依赖
    android {
        ......
        //省略...
        ......
    }
    
    dependencies {
        ......
        implementation rootProject.ext.androidx["legacy-support-v4"]
        implementation rootProject.ext.androidx["androidx-appcompat"]
        implementation rootProject.ext.androidx["androidx.recyclerview"]
        implementation rootProject.ext.androidx["androidx.constraintlayout"]
        implementation rootProject.ext.androidx["androidx.cardview"]
        implementation rootProject.ext.androidx["android.material"]
        ......
    }
    

    相关文章

      网友评论

          本文标题:android studio配置config.gradle统一管

          本文链接:https://www.haomeiwen.com/subject/abkpnhtx.html