@@ -77,12 +77,15 @@ import com.android.build.OutputFile
77
77
* ]
78
78
*/
79
79
80
+ def nodeModulesRoot = " ../../../node_modules"
81
+
80
82
project. ext. react = [
83
+ cliPath : " $nodeModulesRoot /react-native/cli.js" ,
81
84
entryFile : " example/index.js" ,
82
- enableHermes : false , // clean and rebuild if changing
85
+ enableHermes : true , // clean and rebuild if changing
83
86
]
84
87
85
- apply from : " ../../../node_modules /react-native/react.gradle"
88
+ apply from : " $n odeModulesRoot /react-native/react.gradle"
86
89
87
90
/**
88
91
* Set this to true to create two separate APKs instead of one:
@@ -115,19 +118,21 @@ def jscFlavor = 'org.webkit:android-jsc:+'
115
118
/**
116
119
* Whether to enable the Hermes VM.
117
120
*
118
- * This should be set on project.ext.react and mirrored here. If it is not set
121
+ * This should be set on project.ext.react and that value will be read here. If it is not set
119
122
* on project.ext.react, JavaScript will not be compiled to Hermes Bytecode
120
123
* and the benefits of using Hermes will therefore be sharply reduced.
121
124
*/
122
125
def enableHermes = project. ext. react. get(" enableHermes" , false );
123
126
127
+ /**
128
+ * Architectures to build native code for in debug.
129
+ */
130
+ def nativeArchitectures = project. getProperties(). get(" reactNativeDebugArchitectures" )
131
+
124
132
android {
125
- compileSdkVersion rootProject. ext. compileSdkVersion
133
+ ndkVersion rootProject. ext. ndkVersion
126
134
127
- compileOptions {
128
- sourceCompatibility JavaVersion . VERSION_1_8
129
- targetCompatibility JavaVersion . VERSION_1_8
130
- }
135
+ compileSdkVersion rootProject. ext. compileSdkVersion
131
136
132
137
defaultConfig {
133
138
applicationId " com.safeareaviewexample"
@@ -144,9 +149,22 @@ android {
144
149
include " armeabi-v7a" , " x86" , " arm64-v8a" , " x86_64"
145
150
}
146
151
}
152
+ signingConfigs {
153
+ debug {
154
+ storeFile file(' debug.keystore' )
155
+ storePassword ' android'
156
+ keyAlias ' androiddebugkey'
157
+ keyPassword ' android'
158
+ }
159
+ }
147
160
buildTypes {
148
161
debug {
149
162
signingConfig signingConfigs. debug
163
+ if (nativeArchitectures) {
164
+ ndk {
165
+ abiFilters nativeArchitectures. split(' ,' )
166
+ }
167
+ }
150
168
}
151
169
release {
152
170
// Caution! In production, you need to generate your own keystore file.
@@ -162,24 +180,16 @@ android {
162
180
variant. outputs. each { output ->
163
181
// For each separate APK per architecture, set a unique version code as described here:
164
182
// https://developer.android.com/studio/build/configure-apk-splits.html
183
+ // Example: versionCode 1 will generate 1001 for armeabi-v7a, 1002 for x86, etc.
165
184
def versionCodes = [" armeabi-v7a" : 1 , " x86" : 2 , " arm64-v8a" : 3 , " x86_64" : 4 ]
166
185
def abi = output. getFilter(OutputFile . ABI )
167
186
if (abi != null ) { // null for the universal-debug, universal-release variants
168
187
output. versionCodeOverride =
169
- versionCodes . get(abi) * 1048576 + defaultConfig . versionCode
188
+ defaultConfig . versionCode * 1000 + versionCodes . get(abi)
170
189
}
171
190
172
191
}
173
192
}
174
-
175
- packagingOptions {
176
- pickFirst ' **/armeabi-v7a/libc++_shared.so'
177
- pickFirst ' **/x86/libc++_shared.so'
178
- pickFirst ' **/arm64-v8a/libc++_shared.so'
179
- pickFirst ' **/x86_64/libc++_shared.so'
180
- pickFirst ' **/x86/libjsc.so'
181
- pickFirst ' **/armeabi-v7a/libjsc.so'
182
- }
183
193
}
184
194
185
195
dependencies {
@@ -188,22 +198,26 @@ dependencies {
188
198
implementation " com.facebook.react:react-native:+" // From node_modules
189
199
190
200
implementation " androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
201
+
191
202
debugImplementation(" com.facebook.flipper:flipper:${ FLIPPER_VERSION} " ) {
192
- exclude group :' com.facebook.fbjni'
203
+ exclude group :' com.facebook.fbjni'
193
204
}
205
+
194
206
debugImplementation(" com.facebook.flipper:flipper-network-plugin:${ FLIPPER_VERSION} " ) {
195
207
exclude group :' com.facebook.flipper'
208
+ exclude group :' com.squareup.okhttp3' , module :' okhttp'
196
209
}
210
+
197
211
debugImplementation(" com.facebook.flipper:flipper-fresco-plugin:${ FLIPPER_VERSION} " ) {
198
212
exclude group :' com.facebook.flipper'
199
213
}
200
214
201
215
if (enableHermes) {
202
- def hermesPath = " ../../../node_modules/hermesvm /android/" ;
203
- debugImplementation files(hermesPath + " hermes-debug.aar" )
204
- releaseImplementation files(hermesPath + " hermes-release.aar" )
216
+ def hermesPath = " ../../../node_modules/hermes-engine /android/" ;
217
+ debugImplementation files(hermesPath + " hermes-debug.aar" )
218
+ releaseImplementation files(hermesPath + " hermes-release.aar" )
205
219
} else {
206
- implementation jscFlavor
220
+ implementation jscFlavor
207
221
}
208
222
209
223
implementation project(" :react-native-community-async-storage" )
@@ -217,6 +231,6 @@ dependencies {
217
231
// Run this once to be able to run the application with BUCK
218
232
// puts all compile dependencies into folder libs for BUCK to use
219
233
task copyDownloadableDepsToLibs (type : Copy ) {
220
- from configurations. compile
234
+ from configurations. implementation
221
235
into ' libs'
222
236
}
0 commit comments