区块链技术博客
www.b2bchain.cn

Android Studio – 统一项目配置管理求职学习资料

本文介绍了Android Studio – 统一项目配置管理求职学习资料,有助于帮助完成毕业设计以及求职,是一篇很好的资料。

对技术面试,学习经验等有一些体会,在此分享。

起因

项目开发中难免引入各种各样的gradle依赖,本地module包作为项目支持,如果是自己写的module还好,在网上杂七杂八增加了一堆三方库或者三方SDK厂家的包以后,就会有下图的样子
Android Studio - 统一项目配置管理

这图里其实还是个小项目,今天看群友的项目,大概五六个module,每个gradle的compileSdkVersion/buildToolsVersion/minSdkVersion/targetSdkVersion都不一样,导致引入一个新gradle依赖的时候全面报错,给他挨个cv修改了上面4个参数并且升级到29+20.0.2以后项目编译完成.

较好的处理方式

Android Studio - 统一项目配置管理

这里是我使用MVPArms项目框架使用统一配置类,只需要几下cv就可以让项目中的module使用相同的配置,减少了修改复杂度,提高维护性.(可能还提高了编译速度,比如每个module都使用不同版本的buildToolsVersion话,盲猜是会有影响的(未做验证)).

写法

在项目中新建一个config.gradle的文件,config名字随便改,知道他是项目配置文件即可
在项目根gradle文件中,根路径加入apply from: "config.gradle"
Android Studio - 统一项目配置管理

我的config代码如下,有需要的可以去抄一下

ext {      android = [             compileSdkVersion: 29,             buildToolsVersion: "29.0.3",             minSdkVersion    : 23,             targetSdkVersion : 29,             versionCode      : 1,             versionName      : "1.0"     ]      version = [             androidSupportSdkVersion: "29.0.0",             androidXSdkVersion      : "1.1.0",             retrofitSdkVersion      : "2.7.2",             dagger2SdkVersion       : "2.26",             glideSdkVersion         : "4.11.0",             butterknifeSdkVersion   : "10.2.1",             rxlifecycleSdkVersion   : "1.0",             rxlifecycle2SdkVersion  : "2.2.2",             espressoSdkVersion      : "3.0.1",             canarySdkVersion        : "2.2"     ]      dependencies = [             //support             "appcompat-v7"             : "com.android.support:appcompat-v7:${version["androidSupportSdkVersion"]}",             "support-design"           : "com.android.support:design:${version["androidSupportSdkVersion"]}",             "support-v4"               : "com.android.support:support-v4:${version["androidSupportSdkVersion"]}",             "cardview-v7"              : "com.android.support:cardview-v7:${version["androidSupportSdkVersion"]}",             "support-annotations"      : "com.android.support:support-annotations:${version["androidSupportSdkVersion"]}",             "recyclerview-v7"          : "com.android.support:recyclerview-v7:${version["androidSupportSdkVersion"]}",              //androidx             "appcompat"                : "androidx.appcompat:appcompat:${version["androidXSdkVersion"]}",             "design"                   : "com.google.android.material:material:${version["androidXSdkVersion"]}",             "legacy-support-v4"        : "androidx.legacy:legacy-support-v4:1.0.0",             "cardview"                 : "androidx.cardview:cardview:1.0.0",             "annotations"              : "androidx.annotation:annotation:${version["androidXSdkVersion"]}",             "recyclerview"             : "androidx.recyclerview:recyclerview:${version["androidXSdkVersion"]}",              //network             "retrofit"                 : "com.squareup.retrofit2:retrofit:${version["retrofitSdkVersion"]}",             "retrofit-converter-gson"  : "com.squareup.retrofit2:converter-gson:${version["retrofitSdkVersion"]}",             "retrofit-adapter-rxjava"  : "com.squareup.retrofit2:adapter-rxjava:${version["retrofitSdkVersion"]}",             "retrofit-adapter-rxjava2" : "com.squareup.retrofit2:adapter-rxjava2:${version["retrofitSdkVersion"]}",             "okhttp3"                  : "com.squareup.okhttp3:okhttp:3.12.9",             "okhttp4"                  : "com.squareup.okhttp3:okhttp:4.0.0",             "okhttp-urlconnection"     : "com.squareup.okhttp:okhttp-urlconnection:2.0.0",             "glide"                    : "com.github.bumptech.glide:glide:${version["glideSdkVersion"]}",             "glide-compiler"           : "com.github.bumptech.glide:compiler:${version["glideSdkVersion"]}",             "glide-loader-okhttp3"     : "com.github.bumptech.glide:okhttp3-integration:${version["glideSdkVersion"]}", //            "picasso"                  : "com.squareup.picasso:picasso:2.5.2",              //view             "autolayout"               : "com.zhy:autolayout:1.4.5",             "butterknife"              : "com.jakewharton:butterknife:${version["butterknifeSdkVersion"]}",             "butterknife-compiler"     : "com.jakewharton:butterknife-compiler:${version["butterknifeSdkVersion"]}",             "pickerview"               : "com.contrarywind:Android-PickerView:3.2.5",             "photoview"                : "com.github.chrisbanes.photoview:library:1.2.3",             "numberprogressbar"        : "com.daimajia.numberprogressbar:library:1.2@aar",             "nineoldandroids"          : "com.nineoldandroids:library:2.4.0",             "paginate"                 : "com.github.markomilos:paginate:0.5.1",             "vlayout"                  : "com.alibaba.android:vlayout:1.1.0@aar",             "autosize"                 : "me.jessyan:autosize:1.2.1",             "dialog"                   : "com.kongzue.dialog_v3x:dialog:3.1.9",             "XUI"                      : "com.github.xuexiangjys:XUI:1.1.4",             "immersionbar"             : "com.gyf.immersionbar:immersionbar:3.0.0",             "ViewPager2"               : "androidx.viewpager2:viewpager2:1.1.0-alpha01",              //rx1             "rxandroid"                : "io.reactivex:rxandroid:1.2.1",             "rxjava"                   : "io.reactivex:rxjava:1.3.0",             "rxlifecycle"              : "com.trello:rxlifecycle:${version["rxlifecycleSdkVersion"]}",             "rxlifecycle-components"   : "com.trello:rxlifecycle-components:${version["rxlifecycleSdkVersion"]}",             "rxcache"                  : "com.github.VictorAlbertos.RxCache:runtime:1.7.0-1.x",             "rxcache-jolyglot-gson"    : "com.github.VictorAlbertos.Jolyglot:gson:0.0.4",             "rxbinding-recyclerview-v7": "com.jakewharton.rxbinding:rxbinding-recyclerview-v7:1.0.1",             "rxpermissions"            : "com.tbruyelle.rxpermissions:rxpermissions:0.9.4@aar",             "rxerrorhandler"           : "me.jessyan:rxerrorhandler:1.0.1",              //rx2             "rxandroid2"               : "io.reactivex.rxjava2:rxandroid:2.1.1",             "rxjava2"                  : "io.reactivex.rxjava2:rxjava:2.2.18",             "rxlifecycle2"             : "com.trello.rxlifecycle2:rxlifecycle:${version["rxlifecycle2SdkVersion"]}",             "rxlifecycle2-android"     : "com.trello.rxlifecycle2:rxlifecycle-android:${version["rxlifecycle2SdkVersion"]}",             "rxlifecycle2-components"  : "com.trello.rxlifecycle2:rxlifecycle-components:${version["rxlifecycle2SdkVersion"]}",             "rxcache2"                 : "com.github.VictorAlbertos.RxCache:runtime:1.8.3-2.x",             "rxpermissions2"           : "com.github.tbruyelle:rxpermissions:0.10.2",             "rxerrorhandler2"          : "me.jessyan:rxerrorhandler:2.1.1",              //tools             "dagger2"                  : "com.google.dagger:dagger:${version["dagger2SdkVersion"]}",             "dagger2-android"          : "com.google.dagger:dagger-android:${version["dagger2SdkVersion"]}",             "dagger2-android-support"  : "com.google.dagger:dagger-android-support:${version["dagger2SdkVersion"]}",             "dagger2-compiler"         : "com.google.dagger:dagger-compiler:${version["dagger2SdkVersion"]}",             "dagger2-android-processor": "com.google.dagger:dagger-android-processor:${version["dagger2SdkVersion"]}",             "androideventbus"          : "org.simple:androideventbus:1.0.5.1",             "eventbus"                 : "org.greenrobot:eventbus:3.2.0",             "otto"                     : "com.squareup:otto:1.3.8",             "gson"                     : "com.google.code.gson:gson:2.8.6",             "multidex"                 : "com.android.support:multidex:1.0.3",             "javax.annotation"         : "javax.annotation:jsr250-api:1.0",             "arouter"                  : "com.alibaba:arouter-api:1.3.1",             "arouter-compiler"         : "com.alibaba:arouter-compiler:1.1.4",             "progressmanager"          : "me.jessyan:progressmanager:1.5.0",             "retrofit-url-manager"     : "me.jessyan:retrofit-url-manager:1.4.0",             "lifecyclemodel"           : "me.jessyan:lifecyclemodel:1.0.1",              //test             "junit"                    : "junit:junit:4.12",             "androidJUnitRunner"       : "androidx.test.runner.AndroidJUnitRunner",             "runner"                   : "com.android.support.test : runner:1.0.1", //这里冒号左右有空格,报错注意删除             "espresso-core"            : "com.android.support.test.espresso:espresso-core:${version["espressoSdkVersion"]}",             "espresso-contrib"         : "com.android.support.test.espresso:espresso-contrib:${version["espressoSdkVersion"]}",             "espresso-intents"         : "com.android.support.test.espresso:espresso-intents:${version["espressoSdkVersion"]}",             "mockito-core"             : "org.mockito:mockito-core:1.+",             "timber"                   : "com.jakewharton.timber:timber:4.7.1",             "logger"                   : "com.orhanobut:logger:2.2.0", //            "canary-debug"             : "com.squareup.leakcanary:leakcanary-android:${version["canarySdkVersion"]}", //            "canary-release"           : "com.squareup.leakcanary:leakcanary-android-no-op:${version["canarySdkVersion"]}",             "umeng-analytics"          : "com.umeng.analytics:analytics:6.0.1"     ] }

有用得到的库直接拿
这里主要讲ext中的配置
在其他gradle中使用:

compileSdkVersion rootProject.ext.android["compileSdkVersion"] buildToolsVersion rootProject.ext.android["buildToolsVersion"]  minSdkVersion rootProject.ext.android["minSdkVersion"] targetSdkVersion rootProject.ext.android["targetSdkVersion"] versionCode rootProject.ext.android["versionCode"] versionName rootProject.ext.android["versionName"]   implementation rootProject.ext.dependencies["androideventbus"] //view annotationProcessor(rootProject.ext.dependencies["butterknife-compiler"]) {     exclude module: 'annotation' } implementation(rootProject.ext.dependencies["paginate"]) {     exclude module: 'recyclerview' } ... ... ...

诸如此类的用法,有更高级的可以分享一下

起因

项目开发中难免引入各种各样的gradle依赖,本地module包作为项目支持,如果是自己写的module还好,在网上杂七杂八增加了一堆三方库或者三方SDK厂家的包以后,就会有下图的样子
Android Studio - 统一项目配置管理

这图里其实还是个小项目,今天看群友的项目,大概五六个module,每个gradle的compileSdkVersion/buildToolsVersion/minSdkVersion/targetSdkVersion都不一样,导致引入一个新gradle依赖的时候全面报错,给他挨个cv修改了上面4个参数并且升级到29+20.0.2以后项目编译完成.

较好的处理方式

Android Studio - 统一项目配置管理

这里是我使用MVPArms项目框架使用统一配置类,只需要几下cv就可以让项目中的module使用相同的配置,减少了修改复杂度,提高维护性.(可能还提高了编译速度,比如每个module都使用不同版本的buildToolsVersion话,盲猜是会有影响的(未做验证)).

写法

在项目中新建一个config.gradle的文件,config名字随便改,知道他是项目配置文件即可
在项目根gradle文件中,根路径加入apply from: "config.gradle"
Android Studio - 统一项目配置管理

我的config代码如下,有需要的可以去抄一下

ext {      android = [             compileSdkVersion: 29,             buildToolsVersion: "29.0.3",             minSdkVersion    : 23,             targetSdkVersion : 29,             versionCode      : 1,             versionName      : "1.0"     ]      version = [             androidSupportSdkVersion: "29.0.0",             androidXSdkVersion      : "1.1.0",             retrofitSdkVersion      : "2.7.2",             dagger2SdkVersion       : "2.26",             glideSdkVersion         : "4.11.0",             butterknifeSdkVersion   : "10.2.1",             rxlifecycleSdkVersion   : "1.0",             rxlifecycle2SdkVersion  : "2.2.2",             espressoSdkVersion      : "3.0.1",             canarySdkVersion        : "2.2"     ]      dependencies = [             //support             "appcompat-v7"             : "com.android.support:appcompat-v7:${version["androidSupportSdkVersion"]}",             "support-design"           : "com.android.support:design:${version["androidSupportSdkVersion"]}",             "support-v4"               : "com.android.support:support-v4:${version["androidSupportSdkVersion"]}",             "cardview-v7"              : "com.android.support:cardview-v7:${version["androidSupportSdkVersion"]}",             "support-annotations"      : "com.android.support:support-annotations:${version["androidSupportSdkVersion"]}",             "recyclerview-v7"          : "com.android.support:recyclerview-v7:${version["androidSupportSdkVersion"]}",              //androidx             "appcompat"                : "androidx.appcompat:appcompat:${version["androidXSdkVersion"]}",             "design"                   : "com.google.android.material:material:${version["androidXSdkVersion"]}",             "legacy-support-v4"        : "androidx.legacy:legacy-support-v4:1.0.0",             "cardview"                 : "androidx.cardview:cardview:1.0.0",             "annotations"              : "androidx.annotation:annotation:${version["androidXSdkVersion"]}",             "recyclerview"             : "androidx.recyclerview:recyclerview:${version["androidXSdkVersion"]}",              //network             "retrofit"                 : "com.squareup.retrofit2:retrofit:${version["retrofitSdkVersion"]}",             "retrofit-converter-gson"  : "com.squareup.retrofit2:converter-gson:${version["retrofitSdkVersion"]}",             "retrofit-adapter-rxjava"  : "com.squareup.retrofit2:adapter-rxjava:${version["retrofitSdkVersion"]}",             "retrofit-adapter-rxjava2" : "com.squareup.retrofit2:adapter-rxjava2:${version["retrofitSdkVersion"]}",             "okhttp3"                  : "com.squareup.okhttp3:okhttp:3.12.9",             "okhttp4"                  : "com.squareup.okhttp3:okhttp:4.0.0",             "okhttp-urlconnection"     : "com.squareup.okhttp:okhttp-urlconnection:2.0.0",             "glide"                    : "com.github.bumptech.glide:glide:${version["glideSdkVersion"]}",             "glide-compiler"           : "com.github.bumptech.glide:compiler:${version["glideSdkVersion"]}",             "glide-loader-okhttp3"     : "com.github.bumptech.glide:okhttp3-integration:${version["glideSdkVersion"]}", //            "picasso"                  : "com.squareup.picasso:picasso:2.5.2",              //view             "autolayout"               : "com.zhy:autolayout:1.4.5",             "butterknife"              : "com.jakewharton:butterknife:${version["butterknifeSdkVersion"]}",             "butterknife-compiler"     : "com.jakewharton:butterknife-compiler:${version["butterknifeSdkVersion"]}",             "pickerview"               : "com.contrarywind:Android-PickerView:3.2.5",             "photoview"                : "com.github.chrisbanes.photoview:library:1.2.3",             "numberprogressbar"        : "com.daimajia.numberprogressbar:library:1.2@aar",             "nineoldandroids"          : "com.nineoldandroids:library:2.4.0",             "paginate"                 : "com.github.markomilos:paginate:0.5.1",             "vlayout"                  : "com.alibaba.android:vlayout:1.1.0@aar",             "autosize"                 : "me.jessyan:autosize:1.2.1",             "dialog"                   : "com.kongzue.dialog_v3x:dialog:3.1.9",             "XUI"                      : "com.github.xuexiangjys:XUI:1.1.4",             "immersionbar"             : "com.gyf.immersionbar:immersionbar:3.0.0",             "ViewPager2"               : "androidx.viewpager2:viewpager2:1.1.0-alpha01",              //rx1             "rxandroid"                : "io.reactivex:rxandroid:1.2.1",             "rxjava"                   : "io.reactivex:rxjava:1.3.0",             "rxlifecycle"              : "com.trello:rxlifecycle:${version["rxlifecycleSdkVersion"]}",             "rxlifecycle-components"   : "com.trello:rxlifecycle-components:${version["rxlifecycleSdkVersion"]}",             "rxcache"                  : "com.github.VictorAlbertos.RxCache:runtime:1.7.0-1.x",             "rxcache-jolyglot-gson"    : "com.github.VictorAlbertos.Jolyglot:gson:0.0.4",             "rxbinding-recyclerview-v7": "com.jakewharton.rxbinding:rxbinding-recyclerview-v7:1.0.1",             "rxpermissions"            : "com.tbruyelle.rxpermissions:rxpermissions:0.9.4@aar",             "rxerrorhandler"           : "me.jessyan:rxerrorhandler:1.0.1",              //rx2             "rxandroid2"               : "io.reactivex.rxjava2:rxandroid:2.1.1",             "rxjava2"                  : "io.reactivex.rxjava2:rxjava:2.2.18",             "rxlifecycle2"             : "com.trello.rxlifecycle2:rxlifecycle:${version["rxlifecycle2SdkVersion"]}",             "rxlifecycle2-android"     : "com.trello.rxlifecycle2:rxlifecycle-android:${version["rxlifecycle2SdkVersion"]}",             "rxlifecycle2-components"  : "com.trello.rxlifecycle2:rxlifecycle-components:${version["rxlifecycle2SdkVersion"]}",             "rxcache2"                 : "com.github.VictorAlbertos.RxCache:runtime:1.8.3-2.x",             "rxpermissions2"           : "com.github.tbruyelle:rxpermissions:0.10.2",             "rxerrorhandler2"          : "me.jessyan:rxerrorhandler:2.1.1",              //tools             "dagger2"                  : "com.google.dagger:dagger:${version["dagger2SdkVersion"]}",             "dagger2-android"          : "com.google.dagger:dagger-android:${version["dagger2SdkVersion"]}",             "dagger2-android-support"  : "com.google.dagger:dagger-android-support:${version["dagger2SdkVersion"]}",             "dagger2-compiler"         : "com.google.dagger:dagger-compiler:${version["dagger2SdkVersion"]}",             "dagger2-android-processor": "com.google.dagger:dagger-android-processor:${version["dagger2SdkVersion"]}",             "androideventbus"          : "org.simple:androideventbus:1.0.5.1",             "eventbus"                 : "org.greenrobot:eventbus:3.2.0",             "otto"                     : "com.squareup:otto:1.3.8",             "gson"                     : "com.google.code.gson:gson:2.8.6",             "multidex"                 : "com.android.support:multidex:1.0.3",             "javax.annotation"         : "javax.annotation:jsr250-api:1.0",             "arouter"                  : "com.alibaba:arouter-api:1.3.1",             "arouter-compiler"         : "com.alibaba:arouter-compiler:1.1.4",             "progressmanager"          : "me.jessyan:progressmanager:1.5.0",             "retrofit-url-manager"     : "me.jessyan:retrofit-url-manager:1.4.0",             "lifecyclemodel"           : "me.jessyan:lifecyclemodel:1.0.1",              //test             "junit"                    : "junit:junit:4.12",             "androidJUnitRunner"       : "androidx.test.runner.AndroidJUnitRunner",             "runner"                   : "com.android.support.test : runner:1.0.1", //这里冒号左右有空格,报错注意删除             "espresso-core"            : "com.android.support.test.espresso:espresso-core:${version["espressoSdkVersion"]}",             "espresso-contrib"         : "com.android.support.test.espresso:espresso-contrib:${version["espressoSdkVersion"]}",             "espresso-intents"         : "com.android.support.test.espresso:espresso-intents:${version["espressoSdkVersion"]}",             "mockito-core"             : "org.mockito:mockito-core:1.+",             "timber"                   : "com.jakewharton.timber:timber:4.7.1",             "logger"                   : "com.orhanobut:logger:2.2.0", //            "canary-debug"             : "com.squareup.leakcanary:leakcanary-android:${version["canarySdkVersion"]}", //            "canary-release"           : "com.squareup.leakcanary:leakcanary-android-no-op:${version["canarySdkVersion"]}",             "umeng-analytics"          : "com.umeng.analytics:analytics:6.0.1"     ] }

有用得到的库直接拿
这里主要讲ext中的配置
在其他gradle中使用:

compileSdkVersion rootProject.ext.android["compileSdkVersion"] buildToolsVersion rootProject.ext.android["buildToolsVersion"]  minSdkVersion rootProject.ext.android["minSdkVersion"] targetSdkVersion rootProject.ext.android["targetSdkVersion"] versionCode rootProject.ext.android["versionCode"] versionName rootProject.ext.android["versionName"]   implementation rootProject.ext.dependencies["androideventbus"] //view annotationProcessor(rootProject.ext.dependencies["butterknife-compiler"]) {     exclude module: 'annotation' } implementation(rootProject.ext.dependencies["paginate"]) {     exclude module: 'recyclerview' } ... ... ...

诸如此类的用法,有更高级的可以分享一下

起因

项目开发中难免引入各种各样的gradle依赖,本地module包作为项目支持,如果是自己写的module还好,在网上杂七杂八增加了一堆三方库或者三方SDK厂家的包以后,就会有下图的样子
Android Studio - 统一项目配置管理

这图里其实还是个小项目,今天看群友的项目,大概五六个module,每个gradle的compileSdkVersion/buildToolsVersion/minSdkVersion/targetSdkVersion都不一样,导致引入一个新gradle依赖的时候全面报错,给他挨个cv修改了上面4个参数并且升级到29+20.0.2以后项目编译完成.

较好的处理方式

Android Studio - 统一项目配置管理

这里是我使用MVPArms项目框架使用统一配置类,只需要几下cv就可以让项目中的module使用相同的配置,减少了修改复杂度,提高维护性.(可能还提高了编译速度,比如每个module都使用不同版本的buildToolsVersion话,盲猜是会有影响的(未做验证)).

写法

在项目中新建一个config.gradle的文件,config名字随便改,知道他是项目配置文件即可
在项目根gradle文件中,根路径加入apply from: "config.gradle"
Android Studio - 统一项目配置管理

我的config代码如下,有需要的可以去抄一下

ext {      android = [             compileSdkVersion: 29,             buildToolsVersion: "29.0.3",             minSdkVersion    : 23,             targetSdkVersion : 29,             versionCode      : 1,             versionName      : "1.0"     ]      version = [             androidSupportSdkVersion: "29.0.0",             androidXSdkVersion      : "1.1.0",             retrofitSdkVersion      : "2.7.2",             dagger2SdkVersion       : "2.26",             glideSdkVersion         : "4.11.0",             butterknifeSdkVersion   : "10.2.1",             rxlifecycleSdkVersion   : "1.0",             rxlifecycle2SdkVersion  : "2.2.2",             espressoSdkVersion      : "3.0.1",             canarySdkVersion        : "2.2"     ]      dependencies = [             //support             "appcompat-v7"             : "com.android.support:appcompat-v7:${version["androidSupportSdkVersion"]}",             "support-design"           : "com.android.support:design:${version["androidSupportSdkVersion"]}",             "support-v4"               : "com.android.support:support-v4:${version["androidSupportSdkVersion"]}",             "cardview-v7"              : "com.android.support:cardview-v7:${version["androidSupportSdkVersion"]}",             "support-annotations"      : "com.android.support:support-annotations:${version["androidSupportSdkVersion"]}",             "recyclerview-v7"          : "com.android.support:recyclerview-v7:${version["androidSupportSdkVersion"]}",              //androidx             "appcompat"                : "androidx.appcompat:appcompat:${version["androidXSdkVersion"]}",             "design"                   : "com.google.android.material:material:${version["androidXSdkVersion"]}",             "legacy-support-v4"        : "androidx.legacy:legacy-support-v4:1.0.0",             "cardview"                 : "androidx.cardview:cardview:1.0.0",             "annotations"              : "androidx.annotation:annotation:${version["androidXSdkVersion"]}",             "recyclerview"             : "androidx.recyclerview:recyclerview:${version["androidXSdkVersion"]}",              //network             "retrofit"                 : "com.squareup.retrofit2:retrofit:${version["retrofitSdkVersion"]}",             "retrofit-converter-gson"  : "com.squareup.retrofit2:converter-gson:${version["retrofitSdkVersion"]}",             "retrofit-adapter-rxjava"  : "com.squareup.retrofit2:adapter-rxjava:${version["retrofitSdkVersion"]}",             "retrofit-adapter-rxjava2" : "com.squareup.retrofit2:adapter-rxjava2:${version["retrofitSdkVersion"]}",             "okhttp3"                  : "com.squareup.okhttp3:okhttp:3.12.9",             "okhttp4"                  : "com.squareup.okhttp3:okhttp:4.0.0",             "okhttp-urlconnection"     : "com.squareup.okhttp:okhttp-urlconnection:2.0.0",             "glide"                    : "com.github.bumptech.glide:glide:${version["glideSdkVersion"]}",             "glide-compiler"           : "com.github.bumptech.glide:compiler:${version["glideSdkVersion"]}",             "glide-loader-okhttp3"     : "com.github.bumptech.glide:okhttp3-integration:${version["glideSdkVersion"]}", //            "picasso"                  : "com.squareup.picasso:picasso:2.5.2",              //view             "autolayout"               : "com.zhy:autolayout:1.4.5",             "butterknife"              : "com.jakewharton:butterknife:${version["butterknifeSdkVersion"]}",             "butterknife-compiler"     : "com.jakewharton:butterknife-compiler:${version["butterknifeSdkVersion"]}",             "pickerview"               : "com.contrarywind:Android-PickerView:3.2.5",             "photoview"                : "com.github.chrisbanes.photoview:library:1.2.3",             "numberprogressbar"        : "com.daimajia.numberprogressbar:library:1.2@aar",             "nineoldandroids"          : "com.nineoldandroids:library:2.4.0",             "paginate"                 : "com.github.markomilos:paginate:0.5.1",             "vlayout"                  : "com.alibaba.android:vlayout:1.1.0@aar",             "autosize"                 : "me.jessyan:autosize:1.2.1",             "dialog"                   : "com.kongzue.dialog_v3x:dialog:3.1.9",             "XUI"                      : "com.github.xuexiangjys:XUI:1.1.4",             "immersionbar"             : "com.gyf.immersionbar:immersionbar:3.0.0",             "ViewPager2"               : "androidx.viewpager2:viewpager2:1.1.0-alpha01",              //rx1             "rxandroid"                : "io.reactivex:rxandroid:1.2.1",             "rxjava"                   : "io.reactivex:rxjava:1.3.0",             "rxlifecycle"              : "com.trello:rxlifecycle:${version["rxlifecycleSdkVersion"]}",             "rxlifecycle-components"   : "com.trello:rxlifecycle-components:${version["rxlifecycleSdkVersion"]}",             "rxcache"                  : "com.github.VictorAlbertos.RxCache:runtime:1.7.0-1.x",             "rxcache-jolyglot-gson"    : "com.github.VictorAlbertos.Jolyglot:gson:0.0.4",             "rxbinding-recyclerview-v7": "com.jakewharton.rxbinding:rxbinding-recyclerview-v7:1.0.1",             "rxpermissions"            : "com.tbruyelle.rxpermissions:rxpermissions:0.9.4@aar",             "rxerrorhandler"           : "me.jessyan:rxerrorhandler:1.0.1",              //rx2             "rxandroid2"               : "io.reactivex.rxjava2:rxandroid:2.1.1",             "rxjava2"                  : "io.reactivex.rxjava2:rxjava:2.2.18",             "rxlifecycle2"             : "com.trello.rxlifecycle2:rxlifecycle:${version["rxlifecycle2SdkVersion"]}",             "rxlifecycle2-android"     : "com.trello.rxlifecycle2:rxlifecycle-android:${version["rxlifecycle2SdkVersion"]}",             "rxlifecycle2-components"  : "com.trello.rxlifecycle2:rxlifecycle-components:${version["rxlifecycle2SdkVersion"]}",             "rxcache2"                 : "com.github.VictorAlbertos.RxCache:runtime:1.8.3-2.x",             "rxpermissions2"           : "com.github.tbruyelle:rxpermissions:0.10.2",             "rxerrorhandler2"          : "me.jessyan:rxerrorhandler:2.1.1",              //tools             "dagger2"                  : "com.google.dagger:dagger:${version["dagger2SdkVersion"]}",             "dagger2-android"          : "com.google.dagger:dagger-android:${version["dagger2SdkVersion"]}",             "dagger2-android-support"  : "com.google.dagger:dagger-android-support:${version["dagger2SdkVersion"]}",             "dagger2-compiler"         : "com.google.dagger:dagger-compiler:${version["dagger2SdkVersion"]}",             "dagger2-android-processor": "com.google.dagger:dagger-android-processor:${version["dagger2SdkVersion"]}",             "androideventbus"          : "org.simple:androideventbus:1.0.5.1",             "eventbus"                 : "org.greenrobot:eventbus:3.2.0",             "otto"                     : "com.squareup:otto:1.3.8",             "gson"                     : "com.google.code.gson:gson:2.8.6",             "multidex"                 : "com.android.support:multidex:1.0.3",             "javax.annotation"         : "javax.annotation:jsr250-api:1.0",             "arouter"                  : "com.alibaba:arouter-api:1.3.1",             "arouter-compiler"         : "com.alibaba:arouter-compiler:1.1.4",             "progressmanager"          : "me.jessyan:progressmanager:1.5.0",             "retrofit-url-manager"     : "me.jessyan:retrofit-url-manager:1.4.0",             "lifecyclemodel"           : "me.jessyan:lifecyclemodel:1.0.1",              //test             "junit"                    : "junit:junit:4.12",             "androidJUnitRunner"       : "androidx.test.runner.AndroidJUnitRunner",             "runner"                   : "com.android.support.test : runner:1.0.1", //这里冒号左右有空格,报错注意删除             "espresso-core"            : "com.android.support.test.espresso:espresso-core:${version["espressoSdkVersion"]}",             "espresso-contrib"         : "com.android.support.test.espresso:espresso-contrib:${version["espressoSdkVersion"]}",             "espresso-intents"         : "com.android.support.test.espresso:espresso-intents:${version["espressoSdkVersion"]}",             "mockito-core"             : "org.mockito:mockito-core:1.+",             "timber"                   : "com.jakewharton.timber:timber:4.7.1",             "logger"                   : "com.orhanobut:logger:2.2.0", //            "canary-debug"             : "com.squareup.leakcanary:leakcanary-android:${version["canarySdkVersion"]}", //            "canary-release"           : "com.squareup.leakcanary:leakcanary-android-no-op:${version["canarySdkVersion"]}",             "umeng-analytics"          : "com.umeng.analytics:analytics:6.0.1"     ] }

有用得到的库直接拿
这里主要讲ext中的配置
在其他gradle中使用:

compileSdkVersion rootProject.ext.android["compileSdkVersion"] buildToolsVersion rootProject.ext.android["buildToolsVersion"]  minSdkVersion rootProject.ext.android["minSdkVersion"] targetSdkVersion rootProject.ext.android["targetSdkVersion"] versionCode rootProject.ext.android["versionCode"] versionName rootProject.ext.android["versionName"]   implementation rootProject.ext.dependencies["androideventbus"] //view annotationProcessor(rootProject.ext.dependencies["butterknife-compiler"]) {     exclude module: 'annotation' } implementation(rootProject.ext.dependencies["paginate"]) {     exclude module: 'recyclerview' } ... ... ...

诸如此类的用法,有更高级的可以分享一下

部分转自互联网,侵权删除联系

赞(0) 打赏
部分文章转自网络,侵权联系删除b2bchain区块链学习技术社区 » Android Studio – 统一项目配置管理求职学习资料
分享到: 更多 (0)

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

b2b链

联系我们联系我们