@@ -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,9 +97,35 @@ 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
98- buildToolsVersion rootProject. ext. buildToolsVersion
124+
125+ compileOptions {
126+ sourceCompatibility JavaVersion . VERSION_1_8
127+ targetCompatibility JavaVersion . VERSION_1_8
128+ }
99129
100130 defaultConfig {
101131 applicationId " com.example"
@@ -104,46 +134,72 @@ android {
104134 versionCode 1
105135 versionName " 1.0"
106136 }
137+ signingConfigs {
138+ debug {
139+ storeFile file(' debug.keystore' )
140+ storePassword ' android'
141+ keyAlias ' androiddebugkey'
142+ keyPassword ' android'
143+ }
144+ }
107145 splits {
108146 abi {
109147 reset()
110148 enable enableSeparateBuildPerCPUArchitecture
111149 universalApk false // If true, also generate a universal APK
112- include " armeabi-v7a" , " x86" , " arm64-v8a"
150+ include " armeabi-v7a" , " x86" , " arm64-v8a" , " x86_64 "
113151 }
114152 }
115153 buildTypes {
154+ debug {
155+ debuggable true
156+ signingConfig signingConfigs. debug
157+ }
116158 release {
159+ // Caution! In production, you need to generate your own keystore file.
160+ // see https://facebook.github.io/react-native/docs/signed-apk-android.
161+ signingConfig signingConfigs. debug
117162 minifyEnabled enableProguardInReleaseBuilds
118163 proguardFiles getDefaultProguardFile(" proguard-android.txt" ), " proguard-rules.pro"
119164 }
120- debug {
121- debuggable true
122- }
123165 }
124166 // applicationVariants are e.g. debug, release
125167 applicationVariants. all { variant ->
126168 variant. outputs. each { output ->
127169 // 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 ]
170+ // https ://developer .android.com/studio/ build/configure- apk-splits.html
171+ def versionCodes = [" armeabi-v7a" : 1 , " x86" : 2 , " arm64-v8a" : 3 , " x86_64 " : 4 ]
130172 def abi = output. getFilter(OutputFile . ABI )
131173 if (abi != null ) { // null for the universal-debug, universal-release variants
132174 output. versionCodeOverride =
133175 versionCodes. get(abi) * 1048576 + defaultConfig. versionCode
134176 }
177+
135178 }
136179 }
180+
181+ packagingOptions {
182+ pickFirst ' **/armeabi-v7a/libc++_shared.so'
183+ pickFirst ' **/x86/libc++_shared.so'
184+ pickFirst ' **/arm64-v8a/libc++_shared.so'
185+ pickFirst ' **/x86_64/libc++_shared.so'
186+ pickFirst ' **/x86/libjsc.so'
187+ pickFirst ' **/armeabi-v7a/libjsc.so'
188+ }
137189}
138190
139191dependencies {
140- implementation project(' :react-native-custom-tabs' )
141- implementation project(' :react-native-zip-archive' )
142- implementation project(' :react-native-fs' )
143- implementation project(' :react-native-document-picker' )
144192 implementation fileTree(dir : " libs" , include : [" *.jar" ])
145- implementation " com.android.support :appcompat-v7: ${ rootProject.ext.supportLibVersion } "
193+ implementation ' androidx.appcompat :appcompat:1.0.0 '
146194 implementation " com.facebook.react:react-native:+" // From node_modules
195+
196+ if (enableHermes) {
197+ def hermesPath = " ../../node_modules/hermesvm/android/" ;
198+ debugImplementation files(hermesPath + " hermes-debug.aar" )
199+ releaseImplementation files(hermesPath + " hermes-release.aar" )
200+ } else {
201+ implementation jscFlavor
202+ }
147203}
148204
149205// Run this once to be able to run the application with BUCK
@@ -152,3 +208,5 @@ task copyDownloadableDepsToLibs(type: Copy) {
152208 from configurations. compile
153209 into ' libs'
154210}
211+
212+ apply from : file(" ../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle" ); applyNativeModulesAppBuildGradle(project)
0 commit comments