创建config.gradle
ext {
android = [
compileSdkVersion : 26,
buildToolsVersion : "26.0.2",
minSdkVersion : 15,
targetSdkVersion : 26,
versionCode : 1,
versionName : "1.0",
androidSupportVersion: "26.1.0",
]
dependencies = [
"annotations" : "com.android.support:support-annotations:${android["androidSupportVersion"]}",
"appcompat-v7" : "com.android.support:appcompat-v7:${android["androidSupportVersion"]}",
"design" : "com.android.support:design:${android["androidSupportVersion"]}",
]
}
使用
project--gradle
apply from : "config.gradle"
app--gradle
defaultConfig {
applicationId "com.example.ma.demo"
minSdkVersion rootProject.ext.android["minSdkVersion"]
targetSdkVersion rootProject.ext.android["targetSdkVersion"]
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
dependencies {
implementation fileTree(include: [‘*.jar‘], dir: ‘libs‘)
implementation rootProject.ext.dependencies["appcompat-v7"]
}