@@ -15,9 +15,14 @@ import com.android.build.OutputFile
1515 * // the name of the generated asset file containing your JS bundle
1616 * bundleAssetName: "index.android.bundle",
1717 *
18- * // the entry file for bundle generation
18+ * // the entry file for bundle generation. If none specified and
19+ * // "index.android.js" exists, it will be used. Otherwise "index.js" is
20+ * // default. Can be overridden with ENTRY_FILE environment variable.
1921 * entryFile: "index.android.js",
2022 *
23+ * // https://facebook.github.io/react-native/docs/performance#enable-the-ram-format
24+ * bundleCommand: "ram-bundle",
25+ *
2126 * // whether to bundle JS and assets in debug mode
2227 * bundleInDebug: false,
2328 *
@@ -72,6 +77,10 @@ import com.android.build.OutputFile
7277 * ]
7378 */
7479
80+ project. ext. react = [
81+ enableHermes : false , // clean and rebuild if changing
82+ ]
83+
7584apply from : " ../../node_modules/react-native/react.gradle"
7685
7786/**
@@ -89,53 +98,121 @@ def enableSeparateBuildPerCPUArchitecture = false
8998 */
9099def enableProguardInReleaseBuilds = false
91100
101+ /**
102+ * The preferred build flavor of JavaScriptCore.
103+ *
104+ * For example, to use the international variant, you can use:
105+ * `def jscFlavor = 'org.webkit:android-jsc-intl:+'`
106+ *
107+ * The international variant includes ICU i18n library and necessary data
108+ * allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that
109+ * give correct results when using with locales other than en-US. Note that
110+ * this variant is about 6MiB larger per architecture than default.
111+ */
112+ def jscFlavor = ' org.webkit:android-jsc:+'
113+
114+ /**
115+ * Whether to enable the Hermes VM.
116+ *
117+ * This should be set on project.ext.react and mirrored here. If it is not set
118+ * on project.ext.react, JavaScript will not be compiled to Hermes Bytecode
119+ * and the benefits of using Hermes will therefore be sharply reduced.
120+ */
121+ def enableHermes = project. ext. react. get(" enableHermes" , false );
122+
92123android {
93- compileSdkVersion 26
94- buildToolsVersion " 26.0.3"
124+ compileSdkVersion rootProject. ext. compileSdkVersion
125+
126+ compileOptions {
127+ sourceCompatibility JavaVersion . VERSION_1_8
128+ targetCompatibility JavaVersion . VERSION_1_8
129+ }
95130
96131 defaultConfig {
97- applicationId " com.sample "
98- minSdkVersion 16
99- targetSdkVersion 26
132+ applicationId " com.samplesimpledialogs "
133+ minSdkVersion rootProject . ext . minSdkVersion
134+ targetSdkVersion rootProject . ext . targetSdkVersion
100135 versionCode 1
101136 versionName " 1.0"
102- ndk {
103- abiFilters " armeabi-v7a" , " x86"
104- }
105137 }
106138 splits {
107139 abi {
108140 reset()
109141 enable enableSeparateBuildPerCPUArchitecture
110142 universalApk false // If true, also generate a universal APK
111- include " armeabi-v7a" , " x86"
143+ include " armeabi-v7a" , " x86" , " arm64-v8a" , " x86_64"
144+ }
145+ }
146+ signingConfigs {
147+ debug {
148+ storeFile file(' debug.keystore' )
149+ storePassword ' android'
150+ keyAlias ' androiddebugkey'
151+ keyPassword ' android'
112152 }
113153 }
114154 buildTypes {
155+ debug {
156+ signingConfig signingConfigs. debug
157+ }
115158 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
116162 minifyEnabled enableProguardInReleaseBuilds
117163 proguardFiles getDefaultProguardFile(" proguard-android.txt" ), " proguard-rules.pro"
118164 }
119165 }
166+
167+ packagingOptions {
168+ pickFirst " lib/armeabi-v7a/libc++_shared.so"
169+ pickFirst " lib/arm64-v8a/libc++_shared.so"
170+ pickFirst " lib/x86/libc++_shared.so"
171+ pickFirst " lib/x86_64/libc++_shared.so"
172+ }
173+
120174 // applicationVariants are e.g. debug, release
121175 applicationVariants. all { variant ->
122176 variant. outputs. each { output ->
123177 // 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 ]
178+ // https ://developer .android.com/studio/ build/configure- apk-splits.html
179+ def versionCodes = [" armeabi-v7a" : 1 , " x86" : 2 , " arm64-v8a " : 3 , " x86_64 " : 4 ]
126180 def abi = output. getFilter(OutputFile . ABI )
127181 if (abi != null ) { // null for the universal-debug, universal-release variants
128182 output. versionCodeOverride =
129183 versionCodes. get(abi) * 1048576 + defaultConfig. versionCode
130184 }
185+
131186 }
132187 }
133188}
134189
135190dependencies {
136- compile fileTree(dir : " libs" , include : [" *.jar" ])
137- compile " com.android.support:appcompat-v7:${ androidSupportVersion} "
138- compile " com.facebook.react:react-native:+" // From node_modules
191+ implementation fileTree(dir : " libs" , include : [" *.jar" ])
192+ // noinspection GradleDynamicVersion
193+ implementation " com.facebook.react:react-native:+" // From node_modules
194+
195+ implementation " androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
196+
197+ debugImplementation(" com.facebook.flipper:flipper:${ FLIPPER_VERSION} " ) {
198+ exclude group :' com.facebook.fbjni'
199+ }
200+
201+ debugImplementation(" com.facebook.flipper:flipper-network-plugin:${ FLIPPER_VERSION} " ) {
202+ exclude group :' com.facebook.flipper'
203+ }
204+
205+ debugImplementation(" com.facebook.flipper:flipper-fresco-plugin:${ FLIPPER_VERSION} " ) {
206+ exclude group :' com.facebook.flipper'
207+ }
208+
209+ if (enableHermes) {
210+ def hermesPath = " ../../node_modules/hermes-engine/android/" ;
211+ debugImplementation files(hermesPath + " hermes-debug.aar" )
212+ releaseImplementation files(hermesPath + " hermes-release.aar" )
213+ } else {
214+ implementation jscFlavor
215+ }
139216}
140217
141218// Run this once to be able to run the application with BUCK
@@ -144,3 +221,5 @@ task copyDownloadableDepsToLibs(type: Copy) {
144221 from configurations. compile
145222 into ' libs'
146223}
224+
225+ apply from : file(" ../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle" ); applyNativeModulesAppBuildGradle(project)
0 commit comments