@@ -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 : true ,
7781]
7882
7983apply from : " ../../node_modules/react-native/react.gradle"
@@ -93,6 +97,27 @@ 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+ * Whether to enable the Hermes VM.
114+ *
115+ * This should be set on project.ext.react and mirrored here. If it is not set
116+ * on project.ext.react, JavaScript will not be compiled to Hermes Bytecode
117+ * and the benefits of using Hermes will therefore be sharply reduced.
118+ */
119+ def enableHermes = project. ext. react. get(" enableHermes" , true );
120+
96121android {
97122 compileSdkVersion rootProject. ext. compileSdkVersion
98123 compileOptions {
@@ -107,6 +132,14 @@ android {
107132 versionCode 1
108133 versionName " 1.0"
109134 }
135+ signingConfigs {
136+ debug {
137+ storeFile file(' debug.keystore' )
138+ storePassword ' android'
139+ keyAlias ' androiddebugkey'
140+ keyPassword ' android'
141+ }
142+ }
110143 splits {
111144 abi {
112145 reset()
@@ -116,7 +149,13 @@ android {
116149 }
117150 }
118151 buildTypes {
152+ debug {
153+ signingConfig signingConfigs. debug
154+ }
119155 release {
156+ // Caution! In production, you need to generate your own keystore file.
157+ // see https://facebook.github.io/react-native/docs/signed-apk-android.
158+ signingConfig signingConfigs. debug
120159 minifyEnabled enableProguardInReleaseBuilds
121160 proguardFiles getDefaultProguardFile(" proguard-android.txt" ), " proguard-rules.pro"
122161 }
@@ -125,8 +164,8 @@ android {
125164 applicationVariants. all { variant ->
126165 variant. outputs. each { output ->
127166 // For each separate APK per architecture, set a unique version code as described here:
128- // http ://tools .android.com/tech-docs/new- build-system/user-guide/ apk-splits
129- def versionCodes = [" armeabi-v7a" :1 , " x86" :2 , " arm64-v8a" : 3 , " x86_64" : 4 ]
167+ // https ://developer .android.com/studio/ build/configure- apk-splits.html
168+ def versionCodes = [" armeabi-v7a" : 1 , " x86" : 2 , " arm64-v8a" : 3 , " x86_64" : 4 ]
130169 def abi = output. getFilter(OutputFile . ABI )
131170 if (abi != null ) { // null for the universal-debug, universal-release variants
132171 output. versionCodeOverride =
@@ -137,13 +176,15 @@ android {
137176}
138177
139178dependencies {
140- implementation project(' :react-native-vector-icons' )
141- implementation project(' :react-native-localize' )
142- implementation project(' :react-native-linear-gradient' )
143- implementation project(' :react-native-gesture-handler' )
144- implementation fileTree(dir : " libs" , include : [" *.jar" ])
145- implementation " com.android.support:appcompat-v7:${ rootProject.ext.supportLibVersion} "
146179 implementation " com.facebook.react:react-native:+" // From node_modules
180+
181+ if (enableHermes) {
182+ def hermesPath = " ../../node_modules/hermes-engine/android/" ;
183+ debugImplementation files(hermesPath + " hermes-debug.aar" )
184+ releaseImplementation files(hermesPath + " hermes-release.aar" )
185+ } else {
186+ implementation jscFlavor
187+ }
147188}
148189
149190// Run this once to be able to run the application with BUCK
@@ -152,3 +193,5 @@ task copyDownloadableDepsToLibs(type: Copy) {
152193 from configurations. compile
153194 into ' libs'
154195}
196+
197+ apply from : file(" ../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle" ); applyNativeModulesAppBuildGradle(project)
0 commit comments