@@ -9,7 +9,7 @@ import com.android.build.OutputFile
99 * cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the
1010 * bundle directly from the development server. Below you can see all the possible configurations
1111 * 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.
12+ * `apply from: "../../node_modules/react-native/react.gradle"` line.
1313 *
1414 * project.ext.react = [
1515 * // the name of the generated asset file containing your JS bundle
@@ -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,10 +76,11 @@ 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
79- apply from : " ../../../ node_modules/react-native/react.gradle"
83+ apply from : " ../../node_modules/react-native/react.gradle"
8084
8185/**
8286 * Set this to true to create two separate APKs instead of one:
@@ -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
@@ -116,8 +142,22 @@ android {
116142 include " armeabi-v7a" , " x86" , " arm64-v8a" , " x86_64"
117143 }
118144 }
145+ signingConfigs {
146+ debug {
147+ storeFile file(' debug.keystore' )
148+ storePassword ' android'
149+ keyAlias ' androiddebugkey'
150+ keyPassword ' android'
151+ }
152+ }
119153 buildTypes {
154+ debug {
155+ signingConfig signingConfigs. debug
156+ }
120157 release {
158+ // Caution! In production, you need to generate your own keystore file.
159+ // see https://facebook.github.io/react-native/docs/signed-apk-android.
160+ signingConfig signingConfigs. debug
121161 minifyEnabled enableProguardInReleaseBuilds
122162 proguardFiles getDefaultProguardFile(" proguard-android.txt" ), " proguard-rules.pro"
123163 }
@@ -126,21 +166,29 @@ android {
126166 applicationVariants. all { variant ->
127167 variant. outputs. each { output ->
128168 // For each separate APK per architecture, set a unique version code as described here:
129- // http ://tools .android.com/tech-docs/new- build-system/user-guide/ apk-splits
130- def versionCodes = [" armeabi-v7a" :1 , " x86" :2 , " arm64-v8a" : 3 , " x86_64" : 4 ]
169+ // https ://developer .android.com/studio/ build/configure- apk-splits.html
170+ def versionCodes = [" armeabi-v7a" : 1 , " x86" : 2 , " arm64-v8a" : 3 , " x86_64" : 4 ]
131171 def abi = output. getFilter(OutputFile . ABI )
132172 if (abi != null ) { // null for the universal-debug, universal-release variants
133173 output. versionCodeOverride =
134174 versionCodes. get(abi) * 1048576 + defaultConfig. versionCode
135175 }
176+
136177 }
137178 }
138179}
139180
140181dependencies {
141182 implementation fileTree(dir : " libs" , include : [" *.jar" ])
142- implementation " com.android.support:appcompat-v7:${ rootProject.ext.supportLibVersion} "
143183 implementation " com.facebook.react:react-native:+" // From node_modules
184+
185+ if (enableHermes) {
186+ def hermesPath = " ../../node_modules/hermes-engine/android/" ;
187+ debugImplementation files(hermesPath + " hermes-debug.aar" )
188+ releaseImplementation files(hermesPath + " hermes-release.aar" )
189+ } else {
190+ implementation jscFlavor
191+ }
144192}
145193
146194// Run this once to be able to run the application with BUCK
@@ -149,3 +197,5 @@ task copyDownloadableDepsToLibs(type: Copy) {
149197 from configurations. compile
150198 into ' libs'
151199}
200+
201+ apply from : file(" ../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle" ); applyNativeModulesAppBuildGradle(project)
0 commit comments