【发布时间】:2021-10-24 08:08:59
【问题描述】:
我正在尝试将库的版本分开,以便将它们全部放在一个位置,以节省时间和复杂性。
我在某个博客的某条评论中看到一个人,说他是这样做的。他发布了下一个屏幕。
我不能用这种方式来构造gradle,但我认为这是一个好方法。
我的项目 build.gradle 文件:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
// Definition of versions of libraries
ext {
toolVersions = [
android :[
versionCode : 1,
versionName : "0.0.1",
minSdk : 16,
targetSdk : 26,
compileSdk : 26,
buildTools : "26.0.2",
support : "26.1.0"
],
espressoCore : "2.2.2",
junit : "4.12"
]
libVersions = [
glide : "4.2.0",
flubber : "1.0.1"
]
}
我的应用 build.gradle 文件:
apply plugin: 'com.android.application'
android {
compileSdkVersion toolVersions.android.compileSdk
buildToolsVersion toolVersions.android.buildTools
defaultConfig {
applicationId "com.maol.brastlewark"
minSdkVersion toolVersions.android.minSdk
targetSdkVersion toolVersions.android.targetSdk
versionCode toolVersions.android.versionCode
versionName toolVersions.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:' + toolVersion.espressoCore, {
exclude group: 'com.android.support', module: 'support-annotations'
})
// SUPPORT LIBRARIES
compile 'com.android.support:appcompat-v7:' toolVersion.support
compile "com.android.support:support-core-utils:$rootProject.toolVersion.support"
testCompile "junit:junit:$rootProject.toolVersion.junit"
// IMAGE LOADER LIBRARY
compile "com.github.bumptech.glide:glide:$rootProject.libVersions.glide"
annotationProcessor "com.github.bumptech.glide:compiler:$rootProject.libVersions.glide"
// VIEW ANIMATIONS
compile "com.appolica:flubber:$rootProject.libVersions.flubber"
}
我不知道如何在 build.gradle (app) 中使用它。房间里的任何人都可以给我一些建议吗?
谢谢
【问题讨论】:
标签: android gradle android-gradle-plugin build.gradle