@@ -18,6 +18,9 @@ import com.android.build.OutputFile
18
18
* // the entry file for bundle generation
19
19
* entryFile: "index.android.js",
20
20
*
21
+ * // https://facebook.github.io/react-native/docs/performance#enable-the-ram-format
22
+ * bundleCommand: "ram-bundle",
23
+ *
21
24
* // whether to bundle JS and assets in debug mode
22
25
* bundleInDebug: false,
23
26
*
@@ -73,7 +76,8 @@ import com.android.build.OutputFile
73
76
*/
74
77
75
78
project. ext. react = [
76
- entryFile : " index.js"
79
+ entryFile : " index.js" ,
80
+ enableHermes : true , // clean and rebuild if changing
77
81
]
78
82
79
83
apply from : " ../../../node_modules/react-native/react.gradle"
@@ -93,9 +97,36 @@ def enableSeparateBuildPerCPUArchitecture = false
93
97
*/
94
98
def enableProguardInReleaseBuilds = false
95
99
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
+
96
122
android {
97
123
compileSdkVersion rootProject. ext. compileSdkVersion
98
124
125
+ compileOptions {
126
+ sourceCompatibility JavaVersion . VERSION_1_8
127
+ targetCompatibility JavaVersion . VERSION_1_8
128
+ }
129
+
99
130
defaultConfig {
100
131
applicationId " com.reactnativecommunity.viewpager.example"
101
132
minSdkVersion rootProject. ext. minSdkVersion
@@ -108,11 +139,25 @@ android {
108
139
reset()
109
140
enable enableSeparateBuildPerCPUArchitecture
110
141
universalApk false // If true, also generate a universal APK
111
- include " armeabi-v7a" , " x86" , " arm64-v8a"
142
+ include " armeabi-v7a" , " x86" , " arm64-v8a" , " x86_64"
143
+ }
144
+ }
145
+ signingConfigs {
146
+ debug {
147
+ storeFile file(' debug.keystore' )
148
+ storePassword ' android'
149
+ keyAlias ' androiddebugkey'
150
+ keyPassword ' android'
112
151
}
113
152
}
114
153
buildTypes {
154
+ debug {
155
+ signingConfig signingConfigs. debug
156
+ }
115
157
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
116
161
minifyEnabled enableProguardInReleaseBuilds
117
162
proguardFiles getDefaultProguardFile(" proguard-android.txt" ), " proguard-rules.pro"
118
163
}
@@ -121,23 +166,31 @@ android {
121
166
applicationVariants. all { variant ->
122
167
variant. outputs. each { output ->
123
168
// For each separate APK per architecture, set a unique version code as described here:
124
- // http ://tools .android.com/tech-docs/new- build-system/user-guide/ apk-splits
125
- def versionCodes = [" armeabi-v7a" :1 , " x86" :2 , " arm64-v8a" : 3 ]
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 ]
126
171
def abi = output. getFilter(OutputFile . ABI )
127
172
if (abi != null ) { // null for the universal-debug, universal-release variants
128
173
output. versionCodeOverride =
129
174
versionCodes. get(abi) * 1048576 + defaultConfig. versionCode
130
175
}
176
+
131
177
}
132
178
}
133
179
}
134
180
135
181
dependencies {
136
182
implementation fileTree(dir : " libs" , include : [" *.jar" ])
137
- implementation " com.android.support:appcompat-v7:${ rootProject.ext.supportLibVersion} "
138
- // noinspection GradleDynamicVersion
183
+ implementation " androidx.appcompat:appcompat:${ rootProject.ext.appCompatVersion} "
139
184
implementation " com.facebook.react:react-native:+" // From node_modules
140
185
implementation project(' :react-native-viewpager' )
186
+
187
+ if (enableHermes) {
188
+ def hermesPath = " ../../../node_modules/hermes-engine/android/" ;
189
+ debugImplementation files(hermesPath + " hermes-debug.aar" )
190
+ releaseImplementation files(hermesPath + " hermes-release.aar" )
191
+ } else {
192
+ implementation jscFlavor
193
+ }
141
194
}
142
195
143
196
// Run this once to be able to run the application with BUCK
@@ -146,3 +199,6 @@ task copyDownloadableDepsToLibs(type: Copy) {
146
199
from configurations. compile
147
200
into ' libs'
148
201
}
202
+
203
+
204
+ apply from : file(" ../../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle" ); applyNativeModulesAppBuildGradle(project)
0 commit comments