在项目的根目录下新建一个config.gradle
文件:
ext {
android = [
compileSdkVersion: 27,
buildToolsVersion: '27.1.1',
minSdkVersion : 16,
targetSdkVersion : 27
]
androidLibraryVersion = '27.1.1'
dependencies = [
supportV7 : "com.android.support:appcompat-v7:${androidLibraryVersion}",
recyclerView : "com.android.support:recyclerview-v7:${androidLibraryVersion}",
cardView : "com.android.support:cardview-v7:${androidLibraryVersion}",
design : "com.android.support:design:${androidLibraryVersion}",
annotations : "com.android.support:support-annotations:${androidLibraryVersion}",
multidex : 'com.android.support:multidex:1.0.1',
bugly : 'com.tencent.bugly:nativecrashreport:3.3.1',
buglyUpgrade : 'com.tencent.bugly:crashreport_upgrade:1.3.4',
rxjava : 'io.reactivex.rxjava2:rxjava:2.1.2',
rxandroid : 'io.reactivex.rxjava2:rxandroid:2.0.1',
glide : 'com.github.bumptech.glide:glide:4.6.1',
glideOkhttp3 : 'com.github.bumptech.glide:okhttp3-integration:4.6.1',
glideCompiler : 'com.github.bumptech.glide:compiler:4.6.1',
okhttp3 : 'com.squareup.okhttp3:okhttp:3.0.1',
okhttp3LoggingInterceptor: 'com.squareup.okhttp3:logging-interceptor:3.0.1',
retrofit : 'com.squareup.retrofit2:retrofit:2.1.0',
retrofitAdapterRxjava : 'com.squareup.retrofit2:adapter-rxjava2:2.2.0',
retrofitConverterGson : 'com.squareup.retrofit2:converter-gson:2.1.0',
banner : 'com.youth.banner:banner:1.4.10',
exomedia : 'com.devbrackets.android:exomedia:4.1.0'
]
}
在项目根目录下的build.gradle
引入该config.gradle
:
apply from: 'config.gradle'
在子项目引入变量:
def androidConfig = rootProject.ext.android
def libraries = rootProject.ext.dependencies
android {
compileSdkVersion androidConfig.compileSdkVersion
defaultConfig {
applicationId "com.hochan.frameworkstudy"
minSdkVersion androidConfig.minSdkVersion
targetSdkVersion androidConfig.targetSdkVersion
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
annotationProcessor project(':hochan-compiler')
compile project(':hochan-ec')
compile libraries.multidex
}