This repository has been archived by the owner on Jan 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathbuild.gradle
280 lines (242 loc) · 10 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
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
import java.time.LocalDateTime
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.crashlytics'
apply plugin: 'android-aspectjx'
apply plugin: 'AndResGuard'
apply from: "${rootProject.file('loadProperties.gradle')}"
Properties p = loadProps('secret')
android {
compileSdkVersion 31
defaultConfig {
applicationId "com.ryuunoakaihitomi.rebootmenu"
minSdkVersion 19
multiDexEnabled true
// 以下方式会出现这样的错误:android:targetSdkVersion="android-30"
//targetSdkVersion compileSdkVersion
targetSdkVersion 31
// 版本号:发布日期
versionCode 20211224
// 版本名说明: R3.x.y.z (R3:Refactoring 第三次重构,z:Quick Fix序号)
// 不要包含非ASCII可打印字符,会导致Github release文件名异常
versionName 'R3.15.1'
resConfigs "en", "zh-rCN"
buildConfigField 'String', 'BUILD_TIME', '\"' + new Date() + '\"'
}
signingConfigs {
if (p == null) {
logger.lifecycle("Signing info not found. Using debug keystore...")
release {
storeFile debug.storeFile
storePassword debug.storePassword
keyAlias debug.keyAlias
keyPassword debug.keyPassword
}
} else {
release {
keyAlias p['KEY_ALIAS']
keyPassword p['KEY_PWD']
storePassword p['STORE_PWD']
storeFile file(p['STORE_FILE'])
}
}
}
buildTypes {
release {
minifyEnabled true
shrinkResources true
zipAlignEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
firebaseCrashlytics {
mappingFileUploadEnabled true // TODO 此值发布时必须为true
}
signingConfig signingConfigs.release
}
debug {
versionNameSuffix '-debug' +/* 精确判断是不是刚才编译的debug版本 */LocalDateTime.now().format("(dHHmmss)")
}
}
flavorDimensions "version"
productFlavors {
normal {
dimension "version"
if (p != null) buildConfigField 'String', 'AK_APP_CENTER', '\"' + p['APP_CENTER'] + '\"'
}
// Free/Libre and Open Source Software
floss {
dimension "version"
versionNameSuffix '-floss'
applicationId 'github.ryuunoakaihitomi.powerpanel' // 现在想要个新的packageName
}
}
compileOptions {
coreLibraryDesugaringEnabled true
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = "1.8"
}
buildFeatures {
viewBinding true
}
lintOptions {
textReport true
// 实测看上去没有区别
// Resource references will not work correctly in images generated for this vector icon for API < 21; check generated icon to make sure it looks acceptable
disable 'VectorRaster'
}
// https://android-developers.googleblog.com/2020/05/android-studio-4.html
// Dependencies metadata 章节
dependenciesInfo.includeInApk = false
packagingOptions {
exclude 'META-INF/*.version' // 移除记录依赖的版本信息文件(大部分是AndroidX的)
exclude 'androidsupportmultidexversion.txt'
// https://stackoverflow.com/a/41073782/16091156
exclude 'kotlin/**'
// https://github.com/Kotlin/kotlinx.coroutines/issues/2274
exclude 'DebugProbesKt.bin'
// 移除Normal构建中的G组件版本
// https://stackoverflow.com/a/58855506/16091156
exclude 'firebase-*.properties'
exclude 'play-services-*.properties'
exclude 'transport-*.properties'
// jOOR引入的
exclude 'META-INF/README.txt'
}
}
dependencies {
// https://github.com/google/desugar_jdk_libs
// ZXing需要method sort(Ljava/util/Comparator;)V in class Ljava/util/List;
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5'
// https://github.com/androidx/androidx
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.4.0'
implementation 'androidx.multidex:multidex:2.0.1'
def lifecycle_version = "2.4.0"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle_version"
// https://github.com/firebase/firebase-android-sdk
normalImplementation platform('com.google.firebase:firebase-bom:29.0.0')
normalImplementation 'com.google.firebase:firebase-analytics-ktx'
normalImplementation 'com.google.firebase:firebase-crashlytics-ktx'
// https://github.com/microsoft/appcenter-sdk-android
normalImplementation 'com.microsoft.appcenter:appcenter-analytics:4.4.2'
/* ------- 其他第三方开源组件 ------- */
// https://github.com/noties/Markwon
final def markwon_version = '4.6.2'
implementation "io.noties.markwon:core:$markwon_version"
implementation "io.noties.markwon:ext-strikethrough:$markwon_version"
implementation "io.noties.markwon:image:$markwon_version"
// https://github.com/RikkaApps/Shizuku
// https://github.com/RikkaApps/Shizuku-API
def shizuku_version = '12.1.0'
implementation "dev.rikka.shizuku:api:$shizuku_version"
implementation "dev.rikka.shizuku:provider:$shizuku_version"
// https://github.com/ryuunoakaihitomi/PowerAct
implementation 'github.ryuunoakaihitomi.poweract:poweract:1.5.3'
// https://github.com/ryuunoakaihitomi/ReToast
runtimeOnly 'github.ryuunoakaihitomi.retoast:retoast:2.0.0'
// https://github.com/google/gson
implementation 'com.google.code.gson:gson:2.8.9'
// https://github.com/GrenderG/Toasty
implementation 'com.github.GrenderG:Toasty:1.5.2'
// https://github.com/topjohnwu/libsu
implementation 'com.github.topjohnwu.libsu:core:3.2.0'
// https://github.com/apache/commons-io
// 固定在此版本,理由同下段注释 (使用的一些java8 API是脱糖库无法完成转换的,即使脱糖库的文档说明支持)
// java.lang.NoClassDefFoundError: j$.wrappers.$r8$wrapper$java$util$function$Supplier$-WRP
// 目前搜集到的一些资料
// https://issuetracker.google.com/issues/183419297
// https://issuetracker.google.com/issues/157854693
// https://issuetracker.google.com/issues/155005951
// https://issuetracker.google.com/issues/190633902
//noinspection GradleDependency
implementation 'commons-io:commons-io:2.8.0'
// https://github.com/jOOQ/jOOR
implementation 'org.jooq:joor-java-6:0.9.14'
// https://github.com/JakeWharton/timber
implementation 'com.jakewharton.timber:timber:5.0.1'
// https://github.com/PureWriter/about-page
implementation 'com.drakeet.about:about:2.5.0'
// https://github.com/zxing/zxing
implementation 'com.google.zxing:core:3.4.1'
// https://github.com/CyanogenMod/cm_platform_sdk
implementation 'org.cyanogenmod:platform.sdk:6.0'
// https://github.com/LSPosed/AndroidHiddenApiBypass
implementation 'org.lsposed.hiddenapibypass:hiddenapibypass:3.0'
// https://github.com/eclipse/org.aspectj
implementation 'org.aspectj:aspectjrt:1.9.7'
// https://github.com/RikkaApps/RikkaX/tree/master/compatibility
implementation 'dev.rikka.rikkax.compatibility:compatibility:2.0.0'
// https://github.com/square/leakcanary
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.7'
// https://github.com/whataa/pandora
// 最新版是v2.1.0,仅支持android-support
//noinspection GradleDependency
debugImplementation 'com.github.whataa:pandora:androidx_v2.1.0'
}
android.applicationVariants.all { variant ->
// 规格化APK文件名
variant.outputs.all {
outputFileName = "${rootProject.name}-${variant.versionCode}_${variant.versionName}_${variant.buildType.name}.apk"
}
}
repositories {
maven {
url 'https://raw.githubusercontent.com/ryuunoakaihitomi/maven-repository/master'
}
// 上面仓库的镜像
maven {
url 'https://raw.fastgit.org/ryuunoakaihitomi/maven-repository/master'
}
}
// 配置入口和作用点都要制定
aspectjx {
include 'custom_aspect', 'com.drakeet.about'
}
andResGuard {
mappingFile = null
use7zip = true
useSign = true
fixedResName = "_" // 设一个简短的值有利于进一步压缩体积
mergeDuplicatedRes = true
whiteList = [
/*
为了防止混淆后找不到资源并最精简配置,
需要编译一个不使用ARG的release包后手动使用jadx等工具搜索getIdentifier()用法,
并检查resources.arsc以确保豁免项存在。
*/
"R.string.firebase_database_url",
"R.string.gcm_defaultSenderId",
"R.string.project_id",
"R.string.google_app_id",
"R.string.google_api_key",
"R.string.google_storage_bucket",
"R.string.com.crashlytics.android.build_id",
// 使用资源入口名记录事件:getResourceEntryName()
'R.string.func_*',
]
compressFilePattern = [
"*.png",
]
sevenzip {
/* 优先使用环境自带的7z命令 */
def command = "whereis -b 7z"
def shouldUseArtifact = false
try {
def proc = command.execute()
def _7zPath = proc.in.text.split(" ")[1].trim()
logger.lifecycle("Has local 7z bin! $_7zPath")
path = _7zPath
} catch (Exception e) {
logger.lifecycle("Can't find 7z bin! Reason: $e -> Use artifact...")
shouldUseArtifact = true
}
if (shouldUseArtifact) {
artifact = 'io.github.leon406:SevenZip:1.2.22.5'
}
}
digestalg = "SHA-256"
}