-
Notifications
You must be signed in to change notification settings - Fork 0
/
app2.gradle
196 lines (168 loc) · 6.74 KB
/
app2.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
//ext {
// V_CODE = "1"
// V_NAME = "1.0.1"
// schema = "app"
//
// application_id = "com.angcyo.app"
//}
//apply from: allGradle.app
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
//apply plugin: 'com.getkeepsafe.dexcount'
//apply from: 'build_time.gradle'
//apply from: allGradle.appBase
//apply from: allGradle.aar
//apply from: allGradle.key
apply from: "$gradleHost/master/appBase.gradle"
//apply from: "$gradleHost/master/aar.gradle"
apply from: "$gradleHost/master/key.gradle"
static def apkTime() {
return new Date().format("yyyy-MM-dd", TimeZone.getTimeZone("Asia/Shanghai"))
}
def apk_time = apkTime()
def _C_SDK = project.hasProperty("C_SDK") ? project.ext.C_SDK : '31'
def _M_SDK = project.hasProperty("M_SDK") ? project.ext.M_SDK : '21'
def _T_SDK = project.hasProperty("T_SDK") ? project.ext.T_SDK : '31'
def _V_CODE = project.hasProperty("V_CODE") ? project.ext.V_CODE : '1'
def _V_NAME = project.hasProperty("V_NAME") ? project.ext.V_NAME : '1.0'
def application_id = project.hasProperty("application_id") ? project.ext.application_id : 'com.angcyo.app'
def _namespace = project.hasProperty("namespace") ? project.ext.namespace : application_id
def _minify_enabled_debug = project.hasProperty("minify_enabled_debug") ? (project.ext.minify_enabled_debug == "true") : false
def _use_proguard_debug = project.hasProperty("use_proguard_debug") ? (project.ext.use_proguard_debug == "true") : false
def _minify_enabled = project.hasProperty("minify_enabled") ? (project.ext.minify_enabled == "true") : _minify_enabled_debug
def _use_proguard = project.hasProperty("use_proguard") ? (project.ext.use_proguard == "true") : _minify_enabled
println "\n........app.gradle........"
println "工程名->" + project.name + " 包名->" + application_id + " 命名空间->" + _namespace + " 版本->" + _V_NAME + "($_V_CODE)"
println "C_SDK:" + _C_SDK + " M_SDK:" + _M_SDK + " T_SDK:" + _T_SDK + " minify_enabled:" + _minify_enabled + " use_proguard:" + _use_proguard
println "........app.gradle........end"
//println hasProperty("V_NAME")
//println rootProject.hasProperty("V_NAME")
//println project
//println rootProject
android {
namespace "$_namespace" //gradle7.5+
compileSdkVersion Integer.parseInt(_C_SDK)
//buildToolsVersion rootProject.B_TOOLS
defaultConfig {
//vector xml支持 api < 21
//vectorDrawables.useSupportLibrary = true
applicationId "$application_id"
minSdkVersion Integer.parseInt(_M_SDK)
targetSdkVersion Integer.parseInt(_T_SDK)
versionCode Integer.parseInt(_V_CODE)
versionName "$_V_NAME"
multiDexEnabled true
//https://developer.android.com/studio/build/shrink-code?hl=zh-cn#groovy
//resConfigs "zh", "xhdpi" //, "en"
//buildConfigField "boolean", "SHOW_DEBUG", "false"
//可以直接使用 ${applicationId}
// manifestPlaceholders = [
// PACKAGE_NAME: "$application_id"
// ]
// ndk {
// // 设置支持的SO库架构
// abiFilters 'armeabi', 'armeabi-v7a', 'x86', 'x86_64'//, 'arm64-v8a'
// //, 'x86', 'armeabi-v7a', 'x86_64', 'arm64-v8a'
// }
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
//https://developer.android.google.cn/studio/build/multidex.html
multiDexKeepProguard file('multidex-config.pro')
javaCompileOptions {
annotationProcessorOptions {
arguments = ["objectbox.incremental": "true"]
}
}
}
// sourceSets {
// main {
// res.srcDirs = [
// 'src/main/res/'
// ]
// }
// }
/*
flavorDimensions "flavor"
productFlavors {
//develop
_dev {
dimension "flavor"
minSdkVersion Math.max(Integer.parseInt(_M_SDK), 21)
resValue "bool", "is_preview", "true"
}
//preview
pre {
//https://developer.android.com/studio/build/build-variants
//applicationIdSuffix ".pre"
//versionNameSuffix "-pre"
//applicationId "com.acc.xxx.pre"
dimension "flavor"
minSdkVersion Integer.parseInt(_M_SDK)
resValue "bool", "is_preview", "true"
}
//apk
apk {
dimension "flavor"
minSdkVersion Integer.parseInt(_M_SDK)
resValue "bool", "is_preview", "false"
}
}*/
buildTypes {
debug {
//applicationIdSuffix ".debug"
zipAlignEnabled true
shrinkResources false
minifyEnabled _minify_enabled_debug
//useProguard _use_proguard_debug //默认会使用R8压缩优化代码
signingConfig signingConfigs.angcyo
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
debuggable true
jniDebuggable = true
crunchPngs = false
ext.enableCrashlytics = false
ext.alwaysUpdateBuildId = false
resValue "bool", "show_debug", "true"
resValue "bool", "is_debug", "true"
}
/*pretest {
//https://developer.android.com/studio/build/build-variants
//applicationIdSuffix ".pretest"
//manifestPlaceholders = [hostName:"internal.example.com"]
initWith debug
minifyEnabled _minify_enabled
resValue "bool", "show_debug", "true"
resValue "bool", "is_debug", "true"
//匹配回退
matchingFallbacks = ['debug']
}*/
release {
//applicationIdSuffix ".release"
initWith debug
minifyEnabled _minify_enabled
debuggable false
jniDebuggable = false
crunchPngs = true
resValue "bool", "show_debug", "false"
resValue "bool", "is_debug", "false"
}
}
if (gradle.gradleVersion.charAt(0) >= '6') {
//android.packageBuildConfig = false
//https://stackoverflow.com/questions/63072764/android-packagebuildconfig-false-is-deprecated
buildFeatures {
buildConfig = true
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
//https://stackoverflow.com/questions/51957944/android-view-viewonunhandledkeyeventlistener
//https://github.com/DonaldDu/FixUnhandledEvent/
//debugImplementation 'com.github.DonaldDu:FixUnhandledEvent:1.0.1'
}
//apply from: allGradle.version
//apply from: allGradle.collectMR
//apply from: allGradle.apk
apply from: "$gradleHost/master/version.gradle"
apply from: "$gradleHost/master/collectMR.gradle"
//apply from: "$gradleHost/master/apk.gradle"
apply from: "$gradleHost/master/metadata.gradle"