-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Expand file tree
/
Copy pathcommon.gradle
More file actions
72 lines (63 loc) · 2.02 KB
/
common.gradle
File metadata and controls
72 lines (63 loc) · 2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// 通用配置
android {
// 编译源码版本
compileSdk 36
defaultConfig {
// 最低安装版本
minSdk 23
// Android 版本适配指南:https://github.com/getActivity/AndroidVersionAdapter
targetSdk 36
versionName '1.0'
versionCode 10
}
// 支持 Java JDK 8
compileOptions {
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_1_8
}
// 设置存放 so 文件的目录
sourceSets {
main {
jniLibs.srcDirs = ['libs']
}
}
// 可在 Studio 最左侧中的 Build Variants 选项中切换默认的构建类型
buildTypes {
// 调试版本
debug {}
// 预览版本
preview {
matchingFallbacks = ['debug']
}
// 正式版本
release {}
}
// 代码警告配置
lint {
// HardcodedText:禁用文本硬编码警告
// ContentDescription:禁用图片描述警告
disable 'HardcodedText', 'ContentDescription'
}
// 读取 local.properties 文件配置
def properties = new Properties()
def localPropertiesFile = rootProject.file("local.properties")
if (localPropertiesFile.exists()) {
localPropertiesFile.withInputStream { inputStream ->
properties.load(inputStream)
}
}
String buildDirPath = properties.getProperty("build.dir")
if (buildDirPath != null && buildDirPath != "") {
// 将构建文件统一输出到指定的目录下
setBuildDir(new File(buildDirPath, rootProject.name + "/build/${path.replaceAll(':', '/')}"))
} else {
// 将构建文件统一输出到项目根目录下的 build 文件夹
setBuildDir(new File(rootDir, "build/${path.replaceAll(':', '/')}"))
}
}
dependencies {
// 依赖 libs 目录下所有的 jar 和 aar 包
implementation fileTree(include: ['*.jar', '*.aar'], dir: 'libs')
implementation libs.appCompat
implementation libs.material
}