赞
踩
project的bulid.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
apply from: 'config.gradle'
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
setting.gradle
include ':app', ':baidumap', ':mvp', ':rxjava2.0'
module的build.gradle
apply plugin: 'com.android.application'
android {
//编译版本
compileSdkVersion 24
//sdk的buildTool版本
buildToolsVersion "25.0.0"
//默认设置
defaultConfig {
//包名
applicationId "com.example.wulei.demotest"
//最小sdk版本
minSdkVersion 21
//目标sdk版本
targetSdkVersion 24
//版本号
versionCode 1
//版本名称
versionName "1.0"
}
buildTypes {
//发行版本
release {
//是否混淆
minifyEnabled false
//混淆文件
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
//依赖,本地,远程,library
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 'com.android.support:appcompat-v7:24.2.1'
testCompile 'junit:junit:4.12'
compile 'com.android.support:design:24.2.1'
compile 'com.android.support:recyclerview-v7:24.2.1'
compile 'com.android.support:support-v4:24.2.1'
compile 'com.android.support:cardview-v7:24.2.1'
}
如果一个项目中有多个module,而每一个module都要导入多个依赖,如果一个个分别导入,当需要更换版本时,则需要一个个更换修改,很麻烦,所以需要进行管理。
config.gradle
ext {
android = [compileSdkVersion: 24,
buildToolsVersion: "25.0.0",
applicationId : "com.example.wulei.rxjava20",
minSdkVersion : 15,
targetSdkVersion : 24,
VersionCode : 1,
VersionName : "1.0"
]
dependencies = ["support-v4" : 'com.android.support:support-v4:24.2.1',
"appcompat-v7" : 'com.android.support:appcompat-v7:24.2.1',
"recyclerview-v7" : 'com.android.support:recyclerview-v7:24.2.1',
"design" : 'com.android.support:design:24.2.1',
"cardview-v7" : 'com.android.support:cardview-v7:24.2.1',
"rxjava2:rxjava" : 'io.reactivex.rxjava2:rxjava:2.0.3',
"rxjava2:rxandroid" : 'io.reactivex.rxjava2:rxandroid:2.0.1',
"rxjava" : 'io.reactivex:rxjava:1.0.14',
"rxandroid" : 'io.reactivex:rxandroid:1.0.1',
"butterknife" : 'com.jakewharton:butterknife:8.4.0',
"butterknife-compiler": 'com.jakewharton:butterknife-compiler:8.4.0'
]
}
project的bulid.gradle
apply from: 'config.gradle'
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
module的bulid.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"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:24.2.1'
testCompile 'junit:junit:4.12'
compile rootProject.ext.dependencies ["rxjava2:rxjava"]
compile rootProject.ext.dependencies ["rxjava2:rxandroid"]
compile rootProject.ext.dependencies ["butterknife"]
annotationProcessor rootProject.ext.dependencies ["butterknife-compiler"]
}
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。