-
Notifications
You must be signed in to change notification settings - Fork 79
/
build.gradle
354 lines (314 loc) · 13.8 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
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
apply plugin: "com.android.application"
apply plugin: "com.facebook.react"
import com.android.build.OutputFile
import groovy.json.JsonSlurper
/**
* This is the configuration block to customize your React Native Android app.
* By default you don't need to apply any configuration, just uncomment the lines you need.
*/
react {
/* Folders */
// The root of your project, i.e. where "package.json" lives. Default is '..'
// root = file("../")
// The folder where the react-native NPM package is. Default is ../node_modules/react-native
// reactNativeDir = file("../node_modules/react-native")
// The folder where the react-native Codegen package is. Default is ../node_modules/react-native-codegen
// codegenDir = file("../node_modules/react-native-codegen")
// The cli.js file which is the React Native CLI entrypoint. Default is ../node_modules/react-native/cli.js
// cliFile = file("../node_modules/react-native/cli.js")
/* Variants */
// The list of variants to that are debuggable. For those we're going to
// skip the bundling of the JS bundle and the assets. By default is just 'debug'.
// If you add flavors like lite, prod, etc. you'll have to list your debuggableVariants.
// debuggableVariants = ["liteDebug", "prodDebug"]
/* Bundling */
// A list containing the node command and its flags. Default is just 'node'.
// nodeExecutableAndArgs = ["node"]
//
// The command to run when bundling. By default is 'bundle'
// bundleCommand = "ram-bundle"
//
// The path to the CLI configuration file. Default is empty.
// bundleConfig = file(../rn-cli.config.js)
//
// The name of the generated asset file containing your JS bundle
// bundleAssetName = "MyApplication.android.bundle"
//
// The entry file for bundle generation. Default is 'index.android.js' or 'index.js'
// entryFile = file("../js/MyApplication.android.js")
//
// A list of extra flags to pass to the 'bundle' commands.
// See https://github.com/react-native-community/cli/blob/main/docs/commands.md#bundle
// extraPackagerArgs = []
/* Hermes Commands */
// The hermes compiler command to run. By default it is 'hermesc'
// hermesCommand = "$rootDir/my-custom-hermesc/bin/hermesc"
//
// The list of flags to pass to the Hermes compiler. By default is "-O", "-output-source-map"
// hermesFlags = ["-O", "-output-source-map"]
}
project.ext.envConfigFiles = [
// IMPORTANT: longer variants should be first, as react-native-config plugin matches the first prefix it finds
alfajoresnightly: ".env.alfajoresnightly",
alfajoresdev: ".env.alfajoresdev",
alfajores: ".env.alfajores",
mainnetnightly: ".env.mainnetnightly",
mainnetdev: ".env.mainnetdev",
mainnet: ".env.mainnet",
apptest: ".env.test",
"": ".env.alfajoresdev", // Fallback
]
project.ext.sentryCli = [
logLevel: "debug"
]
apply from: project(':react-native-config').projectDir.getPath() + "/dotenv.gradle"
/**
* Build for Detox should be minSdkVersion >= 18
* Use passed property to recognize the build is for detox
*/
def isDetoxTestBuild = Boolean.valueOf(project.properties['isDetoxBuild'] ?: 'false')
if (!isDetoxTestBuild) {
apply from: "../../node_modules/@sentry/react-native/sentry.gradle"
}
/**
* Build used for Android Release Profiling
* Use passed property to recognize the build is for profiling
*/
def isProfilingBuild = Boolean.valueOf(System.env.IS_PROFILING_BUILD ?: 'false')
/**
* Set this to true to create four separate APKs instead of one,
* one for each native architecture. This is useful if you don't
* use App Bundles (https://developer.android.com/guide/app-bundle/)
* and want to have separate APKs to upload to the Play Store.
*/
def enableSeparateBuildPerCPUArchitecture = false
/**
* Set this to true to Run Proguard on Release builds to minify the Java bytecode.
*/
def enableProguardInReleaseBuilds = true
/**
* The preferred build flavor of JavaScriptCore (JSC)
*
* For example, to use the international variant, you can use:
* `def jscFlavor = 'org.webkit:android-jsc-intl:+'`
*
* The international variant includes ICU i18n library and necessary data
* allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that
* give correct results when using with locales other than en-US. Note that
* this variant is about 6MiB larger per architecture than default.
*/
def jscFlavor = 'org.webkit:android-jsc:+'
/**
* Private function to get the list of Native Architectures you want to build.
* This reads the value from reactNativeArchitectures in your gradle.properties
* file and works together with the --active-arch-only flag of react-native run-android.
*/
def reactNativeArchitectures() {
def value = project.getProperties().get("reactNativeArchitectures")
return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
}
def appVersionCode = Integer.valueOf(System.env.CIRCLE_BUILD_NUM ?: VERSION_CODE)
def loadProjectSecrets(String chainName) {
def secretsFile = rootProject.file('../secrets.json')
if (secretsFile.exists()) {
def secrets = new JsonSlurper().parse(secretsFile)
def chainSecrets = secrets.get(chainName)
return chainSecrets instanceof Map ? chainSecrets : [:]
}
return [:]
}
def secrets = loadProjectSecrets(project.env.get("DEFAULT_TESTNET"))
android {
compileSdkVersion rootProject.ext.compileSdkVersion
namespace "org.celo.mobile"
compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
defaultConfig {
applicationId project.env.get("APP_BUNDLE_ID")
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode appVersionCode
versionName "1.87.0"
multiDexEnabled true
testBuildType System.getProperty('testBuildType', 'debug')
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
resValue "string", "app_name", project.env.get("APP_DISPLAY_NAME")
resValue "string", "build_config_package", "org.celo.mobile"
missingDimensionStrategy 'react-native-camera', 'general'
vectorDrawables.useSupportLibrary = true
resValue "bool", "is_profiling_build", System.getenv("IS_PROFILING_BUILD") ?: "false"
manifestPlaceholders = [
auth0Domain: project.env.get("AUTH0_DOMAIN"),
auth0Scheme: "${applicationId}",
clevertapAccountId: secrets['CLEVERTAP_ACCOUNT_ID'] ?: '', // these values cannot be null
clevertapToken: secrets['CLEVERTAP_TOKEN'] ?: ''
]
}
signingConfigs {
release {
if (isDetoxTestBuild || isProfilingBuild) {
storeFile file('debug.keystore')
storePassword 'android'
keyAlias 'androiddebugkey'
keyPassword 'android'
} else if (project.hasProperty('CELO_RELEASE_STORE_FILE')) {
storeFile file(CELO_RELEASE_STORE_FILE)
storePassword System.getenv("CELO_RELEASE_STORE_PASSWORD")
keyAlias CELO_RELEASE_KEY_ALIAS
keyPassword System.getenv("CELO_RELEASE_KEY_PASSWORD")
}
}
debug {
storeFile file('debug.keystore')
storePassword 'android'
keyAlias 'androiddebugkey'
keyPassword 'android'
}
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include (*reactNativeArchitectures())
}
}
buildTypes {
debug {
// uncomment this to test proguard in debug builds
// minifyEnabled true
// proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro", "devsupport.pro"
signingConfig signingConfigs.debug
}
release {
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
if (isDetoxTestBuild) {
// Detox-specific additions to pro-guard
// See https://wix.github.io/Detox/docs/introduction/android/#7-proguard-minification-obfuscation
proguardFile "../../node_modules/detox/android/detox/proguard-rules-app.pro"
proguardFile "detox.pro"
}
signingConfig signingConfigs.release
}
}
flavorDimensions "default"
productFlavors {
alfajores {
dimension "default"
}
alfajoresdev {
dimension "default"
}
alfajoresnightly {
dimension "default"
}
mainnet {
dimension "default"
}
mainnetdev {
dimension "default"
}
mainnetnightly {
dimension "default"
}
// ProductFlavor names cannot start with 'test'
apptest {
dimension "default"
}
}
// applicationVariants are e.g. debug, release
applicationVariants.all { variant ->
variant.outputs.each { output ->
// https://developer.android.com/studio/build/configure-apk-splits.html
def versionCodes = ["armeabi-v7a":1, "x86":2, "arm64-v8a": 4, "x86_64": 5]
def abi = output.getFilter(OutputFile.ABI)
if (abi != null) { // null for the universal-debug, universal-release variants
output.versionCodeOverride =
versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
}
}
}
packagingOptions {
exclude 'META-INF/-no-jdk.kotlin_module'
exclude 'META-INF/androidx.exifinterface_exifinterface.version'
pickFirst '**/libc++_shared.so'
}
}
dependencies {
// Use legacy tag so that Detox uses Java 11
// https://github.com/wix/Detox/releases/tag/20.18.5
androidTestImplementation('com.wix:detox-legacy:+') {
exclude group: 'com.google.android.material'
}
androidTestImplementation('com.linkedin.testbutler:test-butler-library:2.2.1')
implementation 'androidx.multidex:multidex:2.0.1'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
implementation 'com.squareup.okhttp3:okhttp-urlconnection:4.9.0'
// The version of react-native is set by the React Native Gradle Plugin
implementation("com.facebook.react:react-android")
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0"
implementation 'com.clevertap.android:clevertap-android-sdk:5.2.2'
//For CleverTap Android SDK v3.6.4 and above add the following -
implementation 'com.android.installreferrer:installreferrer:2.2'
implementation 'com.google.android.gms:play-services-base:17.4.0'
implementation "com.google.firebase:firebase-messaging:23.0.6"
implementation 'com.google.android.exoplayer:exoplayer:2.17.1'
implementation 'com.google.android.exoplayer:exoplayer-hls:2.17.1'
implementation 'com.google.android.exoplayer:exoplayer-ui:2.17.1'
implementation 'com.github.bumptech.glide:glide:4.11.0'
implementation 'androidx.recyclerview:recyclerview:1.3.2'
implementation 'androidx.viewpager:viewpager:1.0.0'
implementation 'com.google.android.material:material:1.2.1'
implementation 'androidx.core:core:1.4.0'
implementation 'androidx.fragment:fragment:1.3.6'
implementation 'com.android.installreferrer:installreferrer:2.1'
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation project(':clevertap-react-native')
// https://github.com/facebook/react-native/issues/31572#issuecomment-912017067
// TODO: remove this when upgrading RN to 0.68.2
implementation ('androidx.appcompat:appcompat:1.3.1') {
version {
strictly '1.3.1'
}
}
// this fixes an crash on devices with API level 31+ that requires a
// FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent
implementation 'androidx.work:work-runtime:2.7.1'
// this ensures 1.5.0+ version is not picked by
// https://github.com/invertase/react-native-firebase/blob/v11.5.0/packages/auth/android/build.gradle#L88
// which requires minCompileSdk 33
implementation 'androidx.browser:browser:1.4.0'
debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}")
debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
exclude group:'com.squareup.okhttp3', module:'okhttp'
}
debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}")
if (hermesEnabled.toBoolean()) {
implementation("com.facebook.react:hermes-android")
} else {
implementation jscFlavor
}
}
def enableFirebase = project.env.get("FIREBASE_ENABLED")
if (enableFirebase.toBoolean()){
println 'Firebase is enabled in .env variable'
apply plugin: 'com.google.gms.google-services'
} else {
println 'Info: Firebase is disabled in .env variable'
}
apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
// This is to fix a duplicate class error
// Duplicate class org.bouncycastle.LICENSE found in modules jetified-bcprov-jdk15to18-1.69 (org.bouncycastle:bcprov-jdk15to18:1.69) and jetified-bcprov-jdk18on-1.71 (org.bouncycastle:bcprov-jdk18on:1.71)
configurations.all {
c -> c.resolutionStrategy.eachDependency {
DependencyResolveDetails dependency ->
if (dependency.requested.group == 'org.bouncycastle') {
dependency.useTarget 'org.bouncycastle:bcprov-jdk15to18:1.69'
}
}
}