@@ -18,6 +18,9 @@ import com.android.build.OutputFile
1818 * // the entry file for bundle generation
1919 * entryFile: "index.android.js",
2020 *
21+ * // https://facebook.github.io/react-native/docs/performance#enable-the-ram-format
22+ * bundleCommand: "ram-bundle",
23+ *
2124 * // whether to bundle JS and assets in debug mode
2225 * bundleInDebug: false,
2326 *
@@ -73,7 +76,8 @@ import com.android.build.OutputFile
7376 */
7477
7578project. ext. react = [
76- entryFile : " index.js"
79+ entryFile : " index.js" ,
80+ enableHermes : false , // clean and rebuild if changing
7781]
7882
7983apply from : " ../../node_modules/react-native/react.gradle"
@@ -93,6 +97,28 @@ def enableSeparateBuildPerCPUArchitecture = false
9397 */
9498def enableProguardInReleaseBuilds = false
9599
100+ /**
101+ * The preferred build flavor of JavaScriptCore.
102+ *
103+ * For example, to use the international variant, you can use:
104+ * `def jscFlavor = 'org.webkit:android-jsc-intl:+'`
105+ *
106+ * The international variant includes ICU i18n library and necessary data
107+ * allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that
108+ * give correct results when using with locales other than en-US. Note that
109+ * this variant is about 6MiB larger per architecture than default.
110+ */
111+ def jscFlavor = ' org.webkit:android-jsc:+'
112+
113+ /**
114+ * Whether to enable the Hermes VM.
115+ *
116+ * This should be set on project.ext.react and mirrored here. If it is not set
117+ * on project.ext.react, JavaScript will not be compiled to Hermes Bytecode
118+ * and the benefits of using Hermes will therefore be sharply reduced.
119+ */
120+ def enableHermes = project. ext. react. get(" enableHermes" , false );
121+
96122android {
97123 compileSdkVersion rootProject. ext. compileSdkVersion
98124
@@ -119,8 +145,22 @@ android {
119145 include " armeabi-v7a" , " x86" , " arm64-v8a" , " x86_64"
120146 }
121147 }
148+ signingConfigs {
149+ debug {
150+ storeFile file(' debug.keystore' )
151+ storePassword ' android'
152+ keyAlias ' androiddebugkey'
153+ keyPassword ' android'
154+ }
155+ }
122156 buildTypes {
157+ debug {
158+ signingConfig signingConfigs. debug
159+ }
123160 release {
161+ // Caution! In production, you need to generate your own keystore file.
162+ // see https://facebook.github.io/react-native/docs/signed-apk-android.
163+ signingConfig signingConfigs. debug
124164 minifyEnabled enableProguardInReleaseBuilds
125165 proguardFiles getDefaultProguardFile(" proguard-android.txt" ), " proguard-rules.pro"
126166 }
@@ -129,22 +169,38 @@ android {
129169 applicationVariants. all { variant ->
130170 variant. outputs. each { output ->
131171 // For each separate APK per architecture, set a unique version code as described here:
132- // http ://tools .android.com/tech-docs/new- build-system/user-guide/ apk-splits
133- def versionCodes = [" armeabi-v7a" :1 , " x86" :2 , " arm64-v8a" : 3 , " x86_64" : 4 ]
172+ // https ://developer .android.com/studio/ build/configure- apk-splits.html
173+ def versionCodes = [" armeabi-v7a" : 1 , " x86" : 2 , " arm64-v8a" : 3 , " x86_64" : 4 ]
134174 def abi = output. getFilter(OutputFile . ABI )
135175 if (abi != null ) { // null for the universal-debug, universal-release variants
136176 output. versionCodeOverride =
137177 versionCodes. get(abi) * 1048576 + defaultConfig. versionCode
138178 }
179+
139180 }
140181 }
182+
183+ packagingOptions {
184+ pickFirst ' **/armeabi-v7a/libc++_shared.so'
185+ pickFirst ' **/x86/libc++_shared.so'
186+ pickFirst ' **/arm64-v8a/libc++_shared.so'
187+ pickFirst ' **/x86_64/libc++_shared.so'
188+ pickFirst ' **/x86/libjsc.so'
189+ pickFirst ' **/armeabi-v7a/libjsc.so'
190+ }
141191}
142192
143193dependencies {
144- implementation project(' :react-native-app-auth' )
145194 implementation fileTree(dir : " libs" , include : [" *.jar" ])
146- implementation " com.android.support:appcompat-v7:${ rootProject.ext.supportLibVersion} "
147195 implementation " com.facebook.react:react-native:+" // From node_modules
196+
197+ if (enableHermes) {
198+ def hermesPath = " ../../node_modules/hermesvm/android/" ;
199+ debugImplementation files(hermesPath + " hermes-debug.aar" )
200+ releaseImplementation files(hermesPath + " hermes-release.aar" )
201+ } else {
202+ implementation jscFlavor
203+ }
148204}
149205
150206// Run this once to be able to run the application with BUCK
@@ -153,3 +209,5 @@ task copyDownloadableDepsToLibs(type: Copy) {
153209 from configurations. compile
154210 into ' libs'
155211}
212+
213+ apply from : file(" ../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle" ); applyNativeModulesAppBuildGradle(project)
0 commit comments