1、根目录下创建配置文件 dependencies.gradle(同项目build.gradle同一个目录,或引用目录)
ext {
minSdkVersion = 14
compileSdkVersion = 27
targetSdkVersion = 27
hamcrestVersion = '1.3'
junitVersion = '4.12'
runnerVersion = '0.5'
supportVersion = '27.0.2'
supportV4 = "com.android.support:support-v4:$supportVersion"
supportDesign = "com.android.support:design:$supportVersion"
supportAnnotations = "com.android.support:support-annotations:$supportVersion"
supportAppCompat = "com.android.support:appcompat-v7:$supportVersion"
recyclerviewV7 = "com.android.support:recyclerview-v7:$supportVersion"
// Test
junit = "junit:junit:$junitVersion"
testRunner = "com.android.support.test:runner:$runnerVersion"
testRules = "com.android.support.test:rules:$runnerVersion"
// Hamcrest
hamcrestCore = "org.hamcrest:hamcrest-core:$hamcrestVersion"
hamcrestLibrary = "org.hamcrest:hamcrest-library:$hamcrestVersion"
hamcrestIntegration = "org.hamcrest:hamcrest-integration:$hamcrestVersion"
// Other
butterknife = 'com.jakewharton:butterknife:8.5.1'
butterknifeCompiler = 'com.jakewharton:butterknife-compiler:8.5.1'
testDep = [junit,
hamcrestCore,
hamcrestLibrary,
hamcrestIntegration]
androidTestDep = [junit,
testRunner,
testRules,
hamcrestCore,
hamcrestLibrary,
hamcrestIntegration]
}2、根目录build.gradle 中添加引用
apply from: rootProject.file('dependencies.gradle')3、app项目下build.gradle做入选如下修改
apply plugin: 'com.android.application'
android {
compileSdkVersion rootProject.ext.compileSdkVersion
defaultConfig {
applicationId "com.prolificinteractive.materialcalendarview.sample"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0"
}
lintOptions {
abortOnError false
}
}
dependencies {
// You should use the commented out line below in you're application.
// We depend on the source directly here so that development is easier.
implementation project(':library')
//compile 'com.prolificinteractive:material-calendarview:1.4.3'
implementation rootProject.ext.supportAppCompat
implementation rootProject.ext.recyclerviewV7
implementation rootProject.ext.butterknife
annotationProcessor rootProject.ext.butterknifeCompiler
}
本文介绍了Android Studio项目中gradle的基本配置,包括在根目录创建dependencies.gradle文件,然后在根目录build.gradle中引入,最后详细说明了如何修改app模块的build.gradle文件。

10万+

被折叠的 条评论
为什么被折叠?



