common.gradle
5.1 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
if ("app" == project.name) {
apply plugin: 'com.android.application'
} else {
if (isBuildModule.toBoolean()) {
if (project.name == "common" || project.name == "commonRes" || project.name == "network") {
apply plugin: 'com.android.library'
} else {
apply plugin: 'com.android.application'
}
} else {
apply plugin: 'com.android.library'
}
}
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: 'dagger.hilt.android.plugin'
kapt {
arguments {
arg("AROUTER_MODULE_NAME", project.getName())
}
}
kapt {
correctErrorTypes true
}
android {
compileSdkVersion rootProject.ext.android["compileSdkVersion"]
buildToolsVersion rootProject.ext.android["buildToolsVersion"]
useLibrary 'org.apache.http.legacy'
defaultConfig {
if (project.name == "app") {
applicationId rootProject.ext.project["applicationId"]
} else {
if (isBuildModule.toBoolean() && project.name != "common" && project.name != "commonRes" && project.name != "network") {
applicationId rootProject.ext.project["applicationId"] + ".${project.name}"
}
}
minSdkVersion rootProject.ext.android["minSdkVersion"]
targetSdkVersion rootProject.ext.android["targetSdkVersion"]
versionCode rootProject.ext.android["versionCode"]
versionName rootProject.ext.android["versionName"]
testInstrumentationRunner rootProject.ext.dependencies["androidJUnitRunner"]
multiDexEnabled true
ndk {
//选择要添加的对应 cpu 类型的 .so 库。
abiFilters 'armeabi', 'armeabi-v7a'
// 还可以添加 'x86', 'x86_64', 'mips', 'mips64'
}
}
signingConfigs { //签名配置
config {
storeFile file("../sign_tools/lianhe.jsk")
storePassword rootProject.ext.sign["KEYSTORE_PASSWORD"]
keyAlias rootProject.ext.sign["KEY_ALIAS"]
keyPassword rootProject.ext.sign["KEY_PASSWORD"]
v1SigningEnabled true
v2SigningEnabled true
}
}
buildTypes {
debug {
buildConfigField "String", "API_HOST", "${host_debug}"//本地测试
buildConfigField "boolean", "LOG_DEBUG", "true"
buildConfigField "boolean", "IS_BUILD_MODULE", "${isBuildModule}"
minifyEnabled false
signingConfig signingConfigs.config
zipAlignEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
release {
buildConfigField "String", "API_HOST", "${host_api}"//测试地址
buildConfigField "boolean", "LOG_DEBUG", "false"
buildConfigField "boolean", "IS_BUILD_MODULE", "${isBuildModule}"
minifyEnabled false
zipAlignEnabled true
signingConfig signingConfigs.config
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
beta {
buildConfigField "String", "API_HOST", "${host_cs}"//测试地址
buildConfigField "boolean", "LOG_DEBUG", "false"
buildConfigField "boolean", "IS_BUILD_MODULE", "${isBuildModule}"
minifyEnabled false
zipAlignEnabled true
signingConfig signingConfigs.config
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
//sh环境
uat {
buildConfigField "String", "API_HOST", "${host_sh}"//测试地址
buildConfigField "boolean", "LOG_DEBUG", "false"
buildConfigField "boolean", "IS_BUILD_MODULE", "${isBuildModule}"
minifyEnabled false
zipAlignEnabled true
signingConfig signingConfigs.config
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets {
main {
jniLibs.srcDirs = ['libs']
}
}
dataBinding {
enabled = true
}
compileOptions {
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_1_8
}
lintOptions {
disable 'InvalidPackage'
disable "ResourceType"
abortOnError false
}
kotlinOptions {
jvmTarget = "1.8"
}
}
dependencies {
// App dependencies
api fileTree(dir: 'libs', include: ['*.jar'])
// Kotlin
api "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.4.10"
//test
testImplementation 'junit:junit:4.13'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
// Hilt 因为顶部依赖了hilt 插件 apply plugin: 'dagger.hilt.android.plugin' 所以 以下两个hilt的依赖是必须的
api "com.google.dagger:hilt-android:2.29.1-alpha"
kapt "com.google.dagger:hilt-android-compiler:2.29.1-alpha"
//hilt
api 'androidx.hilt:hilt-lifecycle-viewmodel:1.0.0-alpha02'
kapt 'androidx.hilt:hilt-compiler:1.0.0-alpha02'
}