1、 在根目录下添加config.gradle文件
ext{
android=[
compileSdkVersion: 25,
buildToolsVersion: "25.0.3",
applicationId : "ui.huqing.com.demoapp",
minSdkVersion : 14,
targetSdkVersion : 25,
versionCode : 1,
versionName : "1.0"
]
dependencies = [
"appcompat-v7" : 'com.android.support:appcompat-v7:25.+',
"constraint-layout" : 'com.android.support.constraint:constraint-layout:1.0.2',
"circleimageview1" : "de.hdodenhof:circleimageview:2.2.0",
]
}
2、改项目中的build.gradle
原来
改完后
apply plugin: 'com.android.application'
android {
compileSdkVersion rootProject.ext.android.compileSdkVersion
buildToolsVersion rootProject.ext.android.buildToolsVersion
defaultConfig {
applicationId rootProject.ext.android.applicationId
minSdkVersion rootProject.ext.android.minSdkVersion
targetSdkVersion rootProject.ext.android.targetSdkVersion
versionCode rootProject.ext.android.versionCode
versionName rootProject.ext.android.versionName
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
javaCompileOptions {
annotationProcessorOptions {
arguments = [moduleName: project.getName()]
}
}
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
buildConfigField "boolean", "LOG_DEBUG", "true"
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile rootProject.ext.dependencies["constraint-layout"]
compile rootProject.ext.dependencies["appcompat-v7"]
compile rootProject.ext.dependencies["circleimageview1"]
testCompile 'junit:junit:4.12'
}
3、改根目录中的build.gradle
添加 apply from: “config.gradle”