美文网首页
依赖的抽取

依赖的抽取

作者: 君袅 | 来源:发表于2019-03-30 14:23 被阅读0次

    直接在项目中创建config.gradle文件用来存放抽取的依赖

    ext {
    
    
        android = [
                //sdk版本号
                compileSdkVersion    : 27,
                //最小版本号
                minSdkVersion        : 17,
                //最大版本号
                targetSdkVersion     : 27,
                //版本码
                versionCode          : 1,
                //版本名称
                versionName          : "1.0",
    
                androidSupportVersion: "27.1.1",
                retrofitVersion      : "2.3.0",
               butterknifeVersion   : "10.2.1",
                rxJavaVersion        : "2.0.7",
                rxAndroidVersion     : "2.0.1",
                okhttpVersion        : "3.12.0",
                butterknifeVersion   : "8.8.1",
                SmartRefreshVersion  : "1.0.4-7",
                bannerVersion        : "1.4.10",
                xrecyclerviewVersion : "1.5.9",
                glideVersion         : "4.8.0",
                glideTransformVersion: "3.3.0",
                gsonVersion          : "2.6.2",
                materialsearchVersion: "1.4.0",
                stickyHeaderVersion  : "1.0.1",
                eventbusVersion      : "3.1.1",
                jsoupVersion         : "1.11.3",
                disklrucacheVersion  : "2.0.2",
                circleImageVersion   : "2.1.0",
                greendaoVersion      : "3.2.0",
                recyclerviewVersion  : "27.1.1",
    
                recyclerview         : "1.1.0",
    
        ]
    
    
    
        dependencies = [
                 //兼容v7包
                "appcompat-v7"              : "com.android.support:appcompat-v7:${android["androidSupportVersion"]}",
                //tablayout包
                "design"                    : "com.android.support:design:${android["androidSupportVersion"]}",
    
                "retrofit"                  : "com.squareup.retrofit2:retrofit:${android["retrofitVersion"]}",
                "retrofit-adapter-rxjava"   : "com.squareup.retrofit2:adapter-rxjava2:${android["retrofitVersion"]}",
                "retrofit-converter-gson"   : "com.squareup.retrofit2:converter-gson:${android["retrofitVersion"]}",
    
                "rxjava"                    : "io.reactivex.rxjava2:rxjava:${android["rxJavaVersion"]}",
                "rxandroid"                 : "io.reactivex.rxjava2:rxandroid:${android["rxAndroidVersion"]}",
    
                "okhttp"                    : "com.squareup.okhttp3:okhttp:${android["okhttpVersion"]}",
    
                "butterknife"               : "com.jakewharton:butterknife:${android["butterknifeVersion"]}",
                "butterknife-compiler"      : "com.jakewharton:butterknife-compiler:${android["butterknifeVersion"]}",
    
                "SmartRefreshLayout"        : "com.scwang.smartrefresh:SmartRefreshLayout:${android["SmartRefreshVersion"]}",
                "SmartRefreshHeader"        : "com.scwang.smartrefresh:SmartRefreshHeader:${android["SmartRefreshVersion"]}",
    
                "banner"                    : "com.youth.banner:banner:${android["bannerVersion"]}",
    
                "cardView"                  : "com.android.support:cardview-v7:${android["androidSupportVersion"]}",
    
                "xrecyclerview"             : "com.jcodecraeer:xrecyclerview:${android["xrecyclerviewVersion"]}",
    
                "glide"                     : "com.github.bumptech.glide:glide:${android["glideVersion"]}",
                "glideCompiler"       : "com.github.bumptech.glide:compiler:${android["glideVersion"]}",
    
                "transformations"           : "jp.wasabeef:glide-transformations:${android["glideTransformVersion"]}",
    
                "gson"                      : "com.google.code.gson:gson:${android["gsonVersion"]}",
    
                "materialsearchview"        : "com.miguelcatalan:materialsearchview:${android["materialsearchVersion"]}",
    
                "StickyHeaderDecoration"    : "com.github.qdxxxx:StickyHeaderDecoration:${android["stickyHeaderVersion"]}",
    
                "eventbus"                  : "org.greenrobot:eventbus:${android["eventbusVersion"]}",
    
                "jsoup"                     : "org.jsoup:jsoup:${android["jsoupVersion"]}",
    
                "disklrucache"              : "com.jakewharton:disklrucache:${android["disklrucacheVersion"]}",
    
                "circleimageview"           : "de.hdodenhof:circleimageview:${android["circleImageVersion"]}",
    
                "greendao"                  : "org.greenrobot:greendao:${android["greendaoVersion"]}",
                "greendao-generator"        : "org.greenrobot:greendao-generator:${android["greendaoVersion"]}",
    
     "recyclerview"            : "androidx.recyclerview:recyclerview:${android["recyclerview"]}",
        ]
    
    
    }
    

    在项目的build.gradle中进行连接 buildscript 的上面

    
    apply from : "config.gradle"
    
    buildscript {
        
        repositories {
            google()
            jcenter()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:3.1.2'
            
    
            // NOTE: Do not place your application dependencies here; they belong
            // in the individual module build.gradle files
        }
    }
    

    module中使用依赖

    apply plugin: 'com.android.application'
    
    android {
        //版本号
        compileSdkVersion rootProject.ext.android.compileSdkVersion
    
        defaultConfig {
            applicationId "com.example.zhao.navigation"
    
            minSdkVersion rootProject.ext.android.minSdkVersion
            targetSdkVersion rootProject.ext.android.targetSdkVersion
            versionCode rootProject.ext.android.versionCode
            versionName rootProject.ext.android.versionName
     multiDexEnabled true
            testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }
    }
    
    dependencies {
        implementation fileTree(dir: 'libs', include: ['*.jar'])
        implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    
        implementation rootProject.ext.dependencies["appcompat-v7"]
        implementation rootProject.ext.dependencies["design"]
        implementation rootProject.ext.dependencies["retrofit"]
        implementation rootProject.ext.dependencies["retrofit-adapter-rxjava"]
        implementation rootProject.ext.dependencies["retrofit-converter-gson"]
        implementation rootProject.ext.dependencies["rxjava"]
        implementation rootProject.ext.dependencies["rxandroid"]
        implementation rootProject.ext.dependencies["okhttp"]
    
        implementation rootProject.ext.dependencies["butterknife"]
        annotationProcessor rootProject.ext.dependencies["butterknife-compiler"]
    
        implementation rootProject.ext.dependencies["SmartRefreshLayout"]
        implementation rootProject.ext.dependencies["SmartRefreshHeader"]
        implementation rootProject.ext.dependencies["banner"]
        implementation rootProject.ext.dependencies["cardView"]
        implementation rootProject.ext.dependencies["xrecyclerview"]
    
        implementation rootProject.ext.dependencies["glide"]
        annotationProcessor rootProject.ext.dependencies["glideCompiler"]
    
        implementation rootProject.ext.dependencies["transformations"]
        implementation rootProject.ext.dependencies["gson"]
        implementation rootProject.ext.dependencies["materialsearchview"]
    
        implementation rootProject.ext.dependencies["eventbus"]
        implementation rootProject.ext.dependencies["jsoup"]
        implementation rootProject.ext.dependencies["disklrucache"]
        implementation rootProject.ext.dependencies["circleimageview"]
        implementation rootProject.ext.dependencies["greendao"]
        implementation rootProject.ext.dependencies["greendao-generator"]
    
    }
    
    

    相关文章

      网友评论

          本文标题:依赖的抽取

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