AndroidStudio Gradle 第三依赖统一管理,移动端开发技术
// ------------- log 打印工具 -------------
logger : 'com.orhanobut:logger:1.15',
greendao : 'org.greenrobot:greendao:3.2.0',
// ------------- ButterKnife -------------
butterknife : 'com.jakewharton:butterknife:8.4.0',
butterknifeCompiler : 'com.jakewharton:butterknife-compiler:8.4.0',
// ------------- LeakCanary -------------
leakcanaryAndroid : 'com.squareup.leakcanary:leakcanary-android:1.5',
leakcanaryAndroidNoOp: 'com.squareup.leakcanary:leakcanary-android-no-op:1.5',
]
}
2、在我们的 project 中的 build.gradle 中添加
==============================
apply from: "config.gradle"
3、在我们的 module 的 build.gradle 中引入
============================
这是引入之前的 gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "24.0.2"
defaultConfig {
applicationId "com.bandeng.bandeng"
minSdkVersion 15
targetSdkVersion 23
versionC
ode 1
versionName "1.0"
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:23.4.0"
testCompile "junit:junit:4.12"
compile "com.android.support:design:23.4.0"
}
改造之后的 gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion rootProject.ext.android.compileSdkVersion
buildToolsVersion rootProject.ext.android.buildToolsVersion
defaultConfig {
applicationId "com.bandeng.bandeng"
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(rootProject.ext.dependencies.espresso, {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile rootProject.ext.dependencies.appcompatV7
testCompile rootProject.ext.dependencies.junit
compile rootProject.ext.dependencies.design
// 网络请求
compile rootProject.ext.dependencies.okhttp
compile rootProject.ext.dependencies.retrofit
// 图片加载
compile rootProject.ext.dependencies.picasso
// RxJava
评论