1
1
apply plugin : " com.android.application"
2
+ apply plugin : " com.facebook.react"
2
3
3
4
import com.android.build.OutputFile
4
5
5
6
/**
6
- * The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets
7
- * and bundleReleaseJsAndAssets).
8
- * These basically call `react-native bundle` with the correct arguments during the Android build
9
- * cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the
10
- * bundle directly from the development server. Below you can see all the possible configurations
11
- * and their defaults. If you decide to add a configuration block, make sure to add it before the
12
- * `apply from: "../../node_modules/react-native/react.gradle"` line.
13
- *
14
- * project.ext.react = [
15
- * // the name of the generated asset file containing your JS bundle
16
- * bundleAssetName: "index.android.bundle",
17
- *
18
- * // the entry file for bundle generation. If none specified and
19
- * // "index.android.js" exists, it will be used. Otherwise "index.js" is
20
- * // default. Can be overridden with ENTRY_FILE environment variable.
21
- * entryFile: "index.android.js",
22
- *
23
- * // https://reactnative.dev/docs/performance#enable-the-ram-format
24
- * bundleCommand: "ram-bundle",
25
- *
26
- * // whether to bundle JS and assets in debug mode
27
- * bundleInDebug: false,
28
- *
29
- * // whether to bundle JS and assets in release mode
30
- * bundleInRelease: true,
31
- *
32
- * // whether to bundle JS and assets in another build variant (if configured).
33
- * // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants
34
- * // The configuration property can be in the following formats
35
- * // 'bundleIn${productFlavor}${buildType}'
36
- * // 'bundleIn${buildType}'
37
- * // bundleInFreeDebug: true,
38
- * // bundleInPaidRelease: true,
39
- * // bundleInBeta: true,
40
- *
41
- * // whether to disable dev mode in custom build variants (by default only disabled in release)
42
- * // for example: to disable dev mode in the staging build type (if configured)
43
- * devDisabledInStaging: true,
44
- * // The configuration property can be in the following formats
45
- * // 'devDisabledIn${productFlavor}${buildType}'
46
- * // 'devDisabledIn${buildType}'
47
- *
48
- * // the root of your project, i.e. where "package.json" lives
49
- * root: "../../",
50
- *
51
- * // where to put the JS bundle asset in debug mode
52
- * jsBundleDirDebug: "$buildDir/intermediates/assets/debug",
53
- *
54
- * // where to put the JS bundle asset in release mode
55
- * jsBundleDirRelease: "$buildDir/intermediates/assets/release",
56
- *
57
- * // where to put drawable resources / React Native assets, e.g. the ones you use via
58
- * // require('./image.png')), in debug mode
59
- * resourcesDirDebug: "$buildDir/intermediates/res/merged/debug",
60
- *
61
- * // where to put drawable resources / React Native assets, e.g. the ones you use via
62
- * // require('./image.png')), in release mode
63
- * resourcesDirRelease: "$buildDir/intermediates/res/merged/release",
64
- *
65
- * // by default the gradle tasks are skipped if none of the JS files or assets change; this means
66
- * // that we don't look at files in android/ or ios/ to determine whether the tasks are up to
67
- * // date; if you have any other folders that you want to ignore for performance reasons (gradle
68
- * // indexes the entire tree), add them here. Alternatively, if you have JS files in android/
69
- * // for example, you might want to remove it from here.
70
- * inputExcludes: ["android/**", "ios/**"],
71
- *
72
- * // override which node gets called and with what additional arguments
73
- * nodeExecutableAndArgs: ["node"],
74
- *
75
- * // supply additional arguments to the packager
76
- * extraPackagerArgs: []
77
- * ]
7
+ * This is the configuration block to customize your React Native Android app.
8
+ * By default you don't need to apply any configuration, just uncomment the lines you need.
78
9
*/
79
-
80
- project. ext. react = [
81
- enableHermes : false , // clean and rebuild if changing
82
- ]
83
-
84
- apply from : " ../../node_modules/react-native/react.gradle"
10
+ react {
11
+ /* Folders */
12
+ // The root of your project, i.e. where "package.json" lives. Default is '..'
13
+ // root = file("../")
14
+ // The folder where the react-native NPM package is. Default is ../node_modules/react-native
15
+ // reactNativeDir = file("../node_modules/react-native")
16
+ // The folder where the react-native Codegen package is. Default is ../node_modules/react-native-codegen
17
+ // codegenDir = file("../node_modules/react-native-codegen")
18
+ // The cli.js file which is the React Native CLI entrypoint. Default is ../node_modules/react-native/cli.js
19
+ // cliFile = file("../node_modules/react-native/cli.js")
20
+
21
+ /* Variants */
22
+ // The list of variants to that are debuggable. For those we're going to
23
+ // skip the bundling of the JS bundle and the assets. By default is just 'debug'.
24
+ // If you add flavors like lite, prod, etc. you'll have to list your debuggableVariants.
25
+ // debuggableVariants = ["liteDebug", "prodDebug"]
26
+
27
+ /* Bundling */
28
+ // A list containing the node command and its flags. Default is just 'node'.
29
+ // nodeExecutableAndArgs = ["node"]
30
+ //
31
+ // The command to run when bundling. By default is 'bundle'
32
+ // bundleCommand = "ram-bundle"
33
+ //
34
+ // The path to the CLI configuration file. Default is empty.
35
+ // bundleConfig = file(../rn-cli.config.js)
36
+ //
37
+ // The name of the generated asset file containing your JS bundle
38
+ // bundleAssetName = "MyApplication.android.bundle"
39
+ //
40
+ // The entry file for bundle generation. Default is 'index.android.js' or 'index.js'
41
+ // entryFile = file("../js/MyApplication.android.js")
42
+ //
43
+ // A list of extra flags to pass to the 'bundle' commands.
44
+ // See https://github.com/react-native-community/cli/blob/main/docs/commands.md#bundle
45
+ // extraPackagerArgs = []
46
+
47
+ /* Hermes Commands */
48
+ // The hermes compiler command to run. By default it is 'hermesc'
49
+ // hermesCommand = "$rootDir/my-custom-hermesc/bin/hermesc"
50
+ //
51
+ // The list of flags to pass to the Hermes compiler. By default is "-O", "-output-source-map"
52
+ // hermesFlags = ["-O", "-output-source-map"]
53
+ }
85
54
86
55
project. ext. vectoricons = [
87
56
iconFontNames : [' Ionicons.ttf' ]
@@ -90,52 +59,47 @@ project.ext.vectoricons = [
90
59
apply from : " ../../node_modules/react-native-vector-icons/fonts.gradle"
91
60
92
61
/**
93
- * Set this to true to create two separate APKs instead of one:
94
- * - An APK that only works on ARM devices
95
- * - An APK that only works on x86 devices
96
- * The advantage is the size of the APK is reduced by about 4MB.
97
- * Upload all the APKs to the Play Store and people will download
98
- * the correct one based on the CPU architecture of their device.
62
+ * Set this to true to create four separate APKs instead of one,
63
+ * one for each native architecture. This is useful if you don't
64
+ * use App Bundles (https://developer.android.com/guide/app-bundle/)
65
+ * and want to have separate APKs to upload to the Play Store.
99
66
*/
100
67
def enableSeparateBuildPerCPUArchitecture = false
101
68
102
69
/**
103
- * Run Proguard to shrink the Java bytecode in release builds .
70
+ * Set this to true to Run Proguard on Release builds to minify the Java bytecode.
104
71
*/
105
72
def enableProguardInReleaseBuilds = false
106
73
107
74
/**
108
- * The preferred build flavor of JavaScriptCore.
75
+ * The preferred build flavor of JavaScriptCore (JSC)
109
76
*
110
77
* For example, to use the international variant, you can use:
111
78
* `def jscFlavor = 'org.webkit:android-jsc-intl:+'`
112
79
*
113
80
* The international variant includes ICU i18n library and necessary data
114
81
* allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that
115
- * give correct results when using with locales other than en-US. Note that
82
+ * give correct results when using with locales other than en-US. Note that
116
83
* this variant is about 6MiB larger per architecture than default.
117
84
*/
118
85
def jscFlavor = ' org.webkit:android-jsc:+'
119
86
120
87
/**
121
- * Whether to enable the Hermes VM.
122
- *
123
- * This should be set on project.ext.react and mirrored here. If it is not set
124
- * on project.ext.react, JavaScript will not be compiled to Hermes Bytecode
125
- * and the benefits of using Hermes will therefore be sharply reduced.
126
- */
127
- def enableHermes = project. ext. react. get(" enableHermes" , false );
128
-
129
- /**
130
- * Architectures to build native code for in debug.
88
+ * Private function to get the list of Native Architectures you want to build.
89
+ * This reads the value from reactNativeArchitectures in your gradle.properties
90
+ * file and works together with the --active-arch-only flag of react-native run-android.
131
91
*/
132
- def nativeArchitectures = project. getProperties(). get(" reactNativeDebugArchitectures" )
92
+ def reactNativeArchitectures () {
93
+ def value = project. getProperties(). get(" reactNativeArchitectures" )
94
+ return value ? value. split(" ," ) : [" armeabi-v7a" , " x86" , " x86_64" , " arm64-v8a" ]
95
+ }
133
96
134
97
android {
135
98
ndkVersion rootProject. ext. ndkVersion
136
99
137
100
compileSdkVersion rootProject. ext. compileSdkVersion
138
101
102
+ namespace " com.instabug.react.example"
139
103
defaultConfig {
140
104
applicationId " com.instabug.react.example"
141
105
minSdkVersion rootProject. ext. minSdkVersion
@@ -146,12 +110,13 @@ android {
146
110
testBuildType System . getProperty(' testBuildType' , ' debug' ) // This will later be used to control the test apk build type
147
111
testInstrumentationRunner ' androidx.test.runner.AndroidJUnitRunner'
148
112
}
113
+
149
114
splits {
150
115
abi {
151
116
reset()
152
117
enable enableSeparateBuildPerCPUArchitecture
153
118
universalApk false // If true, also generate a universal APK
154
- include " armeabi-v7a " , " x86 " , " arm64-v8a " , " x86_64 "
119
+ include ( * reactNativeArchitectures())
155
120
}
156
121
}
157
122
signingConfigs {
@@ -165,18 +130,14 @@ android {
165
130
buildTypes {
166
131
debug {
167
132
signingConfig signingConfigs. debug
168
- if (nativeArchitectures) {
169
- ndk {
170
- abiFilters nativeArchitectures. split(' ,' )
171
- }
172
- }
173
133
}
174
134
release {
175
135
// Caution! In production, you need to generate your own keystore file.
176
136
// see https://reactnative.dev/docs/signed-apk-android.
177
137
signingConfig signingConfigs. debug
178
138
minifyEnabled enableProguardInReleaseBuilds
179
139
proguardFiles getDefaultProguardFile(" proguard-android.txt" ), " proguard-rules.pro"
140
+ proguardFile " ${ rootProject.projectDir} /../node_modules/detox/android/detox/proguard-rules-app.pro"
180
141
}
181
142
}
182
143
@@ -198,29 +159,19 @@ android {
198
159
}
199
160
200
161
dependencies {
201
- implementation fileTree(dir : " libs" , include : [" *.jar" ])
202
- // noinspection GradleDynamicVersion
203
- implementation " com.facebook.react:react-native:+" // From node_modules
204
- implementation " androidx.multidex:multidex:2.0.1"
205
- implementation " androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
206
-
207
- debugImplementation(" com.facebook.flipper:flipper:${ FLIPPER_VERSION} " ) {
208
- exclude group :' com.facebook.fbjni'
209
- }
162
+ // The version of react-native is set by the React Native Gradle Plugin
163
+ implementation(" com.facebook.react:react-android" )
164
+
165
+ implementation(" androidx.swiperefreshlayout:swiperefreshlayout:1.0.0" )
210
166
167
+ debugImplementation(" com.facebook.flipper:flipper:${ FLIPPER_VERSION} " )
211
168
debugImplementation(" com.facebook.flipper:flipper-network-plugin:${ FLIPPER_VERSION} " ) {
212
- exclude group :' com.facebook.flipper'
213
169
exclude group :' com.squareup.okhttp3' , module :' okhttp'
214
170
}
215
171
216
- debugImplementation(" com.facebook.flipper:flipper-fresco-plugin:${ FLIPPER_VERSION} " ) {
217
- exclude group :' com.facebook.flipper'
218
- }
219
-
220
- if (enableHermes) {
221
- def hermesPath = " ../../node_modules/hermes-engine/android/" ;
222
- debugImplementation files(hermesPath + " hermes-debug.aar" )
223
- releaseImplementation files(hermesPath + " hermes-release.aar" )
172
+ debugImplementation(" com.facebook.flipper:flipper-fresco-plugin:${ FLIPPER_VERSION} " )
173
+ if (hermesEnabled. toBoolean()) {
174
+ implementation(" com.facebook.react:hermes-android" )
224
175
} else {
225
176
implementation jscFlavor
226
177
}
@@ -230,11 +181,4 @@ dependencies {
230
181
androidTestImplementation ' junit:junit:4.12'
231
182
}
232
183
233
- // Run this once to be able to run the application with BUCK
234
- // puts all compile dependencies into folder libs for BUCK to use
235
- task copyDownloadableDepsToLibs (type : Copy ) {
236
- from configurations. implementation
237
- into ' libs'
238
- }
239
-
240
184
apply from : file(" ../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle" ); applyNativeModulesAppBuildGradle(project)
0 commit comments