/
build.gradle
228 lines (207 loc) · 8.05 KB
/
build.gradle
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-parcelize'
//apply plugin: 'com.performance.optimize'
//获取时间戳
static def getDate() {
def date = new Date()
def formattedDate = date.format('yyyyMMddHHmm')
return formattedDate
}
android {
compileSdkVersion App.compileSdkVersion
defaultConfig {
applicationId App.appId
minSdkVersion App.minSdkVersion
targetSdkVersion App.targetSdkVersion
versionCode App.versionCode
versionName App.versionName
multiDexEnabled true
vectorDrawables.useSupportLibrary = true
buildConfigField "boolean", "IS_SHOW_LOG", "false"
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
vectorDrawables.useSupportLibrary = true
ndk {
abiFilters "armeabi-v7a"
}
}
sourceSets {
main {
java.srcDirs = ['src/main/java', 'src/main/aidl', 'src/main/kotlin']
}
}
compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
}
// For Kotlin projects
kotlinOptions {
jvmTarget = "1.8"
}
buildFeatures {
//开启 Compose 功能
compose = true
}
composeOptions {
//配置Kotlin编译器扩展版本, 需要与 Kotlin 版本控制相关联
//对应关系:https://developer.android.com/jetpack/androidx/releases/compose-kotlin?hl=zh-cn
kotlinCompilerExtensionVersion compose_version
kotlinCompilerVersion kotlin_version //在AGP7.0+版本上不用配置这个了
}
buildTypes {
release {
minifyEnabled false
buildConfigField "boolean", "IS_SHOW_LOG", "false"
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
multiDexKeepProguard = file('multidex-config.pro')
}
debug {
debuggable true
minifyEnabled false
shrinkResources false
buildConfigField "boolean", "IS_SHOW_LOG", "true"
//signingConfig signingConfigs.release
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
multiDexKeepProguard = file('multidex-config.pro')
}
// preview {
// minifyEnabled false
// buildConfigField "boolean", "IS_SHOW_LOG", "true"
// }
}
flavorDimensions "api"
productFlavors {
huidu {
dimension "api"
}
xiaomi {
dimension "api"
}
huawei {
dimension "api"
}
oppo {
dimension "api"
}
vivi {
dimension "api"
}
productFlavors.findAll {
flavor -> flavor.manifestPlaceholders = [KEY_VALUE: "${flavor.name}"]
}
}
packagingOptions {
resources {
excludes += '/META-INF/{AL2.0,LGPL2.1}'
}
}
//修改APK生成名字 通过android.applicationVariants索引来遍历所有的 build variant
applicationVariants.each { variant ->
variant.outputs.each {
def timeNow = getDate()
def newName
if (variant.buildType.name == 'debug') {
newName = "android-" + timeNow + "_v${variant.versionName}-debug.apk"
} else {
newName = "android_${variant.flavorName}_" + timeNow + "_v${variant.versionName}_${variant.buildType.name}.apk"
}
output.outputFile = new File(output.outputFile.parent, newName)
}
}
}
dependencies {
//AndroidX相关
implementation Deps.kotlinStdlib
implementation Deps.androidx_material
implementation Deps.androidx_appcompat
implementation Deps.androidx_recyclerView
implementation Deps.androidx_constraintLayout
implementation Deps.androidx_legacy
implementation Deps.androidx_multidex
//协程
implementation Deps.coroutines_core
implementation Deps.coroutines_android
//Jetpack相关
implementation Deps.jetpack_lifecycle_process //lifecycle_process
implementation Deps.jetpack_lifecycle_service //lifecycle_service
implementation Deps.jetpack_livedata //livedata
implementation Deps.jetpack_activity_ktx //activity_ktx
implementation Deps.jetpack_fragment_ktx //fragment_ktx
implementation Deps.jetpack_viewmodel //viewmodel
implementation Deps.jetpack_lifecycle_runtime //lifecycleScope
implementation Deps.jetpack_datastore //datastore
implementation Deps.jetpack_datastore_pf //datastore_preferences
/**
* Compose 相关配置
*/
implementation 'androidx.activity:activity-compose:1.3.1'
//Compose Runtime: Compose 编程模型和状态管理的基本构建块,以及 Compose 编译器插件的目标核心运行时。
//https://developer.android.com/jetpack/androidx/releases/compose-runtime?hl=zh-cn
implementation "androidx.compose.runtime:runtime:$compose_version"
implementation "androidx.compose.runtime:runtime-livedata:$compose_version"
//Compose中使用ViewModel
implementation "androidx.lifecycle:lifecycle-viewmodel-compose:2.6.0-alpha01"
//StateFlow<T>.collectAsStateWithLifecycle()
implementation "androidx.lifecycle:lifecycle-runtime-compose:2.6.0-alpha01"
implementation "androidx.compose.ui:ui:$compose_version"
implementation "androidx.compose.foundation:foundation:$compose_version"
implementation "androidx.compose.foundation:foundation-layout:$compose_version"
implementation "androidx.compose.material:material:$compose_version"
implementation "androidx.compose.ui:ui-tooling:$compose_version"
implementation "com.google.android.material:compose-theme-adapter:$compose_version"
// Import the Compose BOM
// implementation platform('androidx.compose:compose-bom:2022.10.00')
// // Import other Compose libraries without version numbers
// // ..
// implementation 'androidx.compose.ui:ui'
// implementation 'androidx.compose.foundation:foundation'
/**
* Room相关
*/
implementation "androidx.room:room-runtime:$room_version"
//annotationProcessor "androidx.room:room-compiler:$room_version"
kapt "androidx.room:room-compiler:$room_version" // To use Kotlin annotation processing tool (kapt)
//ksp "androidx.room:room-compiler:$room_version" // To use Kotlin Symbol Processing (KSP)
implementation("androidx.room:room-ktx:$room_version") //Kotlin Extensions and Coroutines support for Room
//okhttp
implementation Deps.okhttp
implementation Deps.okhttp_log_interceptor
//retrofit
implementation Deps.retrofit
implementation Deps.retrofit_converter_gson
//汉字转拼音,通讯录 https://github.com/promeG/TinyPinyin
// TinyPinyin核心包,约80KB
// 可选,适用于Android的中国地区词典
implementation 'com.github.promeg:tinypinyin:2.0.3'
implementation 'com.github.promeg:tinypinyin-lexicons-android-cncity:2.0.3'
implementation fileTree(dir: 'libs', include: ['*.jar'])
/**
* markdown渲染
*/
def markwon_version = "4.6.2"
implementation "io.noties.markwon:core:$markwon_version"
implementation "io.noties.markwon:ext-latex:$markwon_version"
implementation "io.noties.markwon:html:$markwon_version"
implementation "io.noties.markwon:inline-parser:$markwon_version"
api project(':lib_protobuf')
if (compileMVPager2WithSource == "1") {
//源码方式集成
api project(':lib_viewpager2')
} else {
implementation 'io.github.mqcodedev:lib_mvpager2:1.0.0-rc3'
}
if (compileDialogWithSource == "1") {
//源码方式集成
api project(':lib_dialog')
} else {
//aar方式集成
implementation 'io.github.mqcodedev:lib_dialog:1.3.0' //maven仓库
//implementation 'com.ninetripods:lib-dialog:1.1.0' //Jcenter仓库 后续不再更新 建议使用maven方式引入
}
}
//gradle.taskGraph.whenReady {
// it.allTasks.forEach { task ->
// println("${task.name}: ${task.class.name - '_Decorated'}")
// }
//}