@@ -3,129 +3,67 @@ apply plugin: "com.android.application"
33import com.android.build.OutputFile
44
55/**
6- * The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets
7- * and bundleReleaseJsAndAssets).
8- * These basically call `react-native bundle` with the correct arguments during the Android build
9- * cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the
10- * bundle directly from the development server. Below you can see all the possible configurations
11- * 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.
13- *
14- * project.ext.react = [
15- * // the name of the generated asset file containing your JS bundle
16- * bundleAssetName: "index.android.bundle",
17- *
18- * // the entry file for bundle generation
19- * entryFile: "index.android.js",
20- *
21- * // https://reactnative.dev/docs/performance#enable-the-ram-format
22- * bundleCommand: "ram-bundle",
23- *
24- * // whether to bundle JS and assets in debug mode
25- * bundleInDebug: false,
26- *
27- * // whether to bundle JS and assets in release mode
28- * bundleInRelease: true,
29- *
30- * // whether to bundle JS and assets in another build variant (if configured).
31- * // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants
32- * // The configuration property can be in the following formats
33- * // 'bundleIn${productFlavor}${buildType}'
34- * // 'bundleIn${buildType}'
35- * // bundleInFreeDebug: true,
36- * // bundleInPaidRelease: true,
37- * // bundleInBeta: true,
38- *
39- * // whether to disable dev mode in custom build variants (by default only disabled in release)
40- * // for MultipleImagePickerExample: to disable dev mode in the staging build type (if configured)
41- * devDisabledInStaging: true,
42- * // The configuration property can be in the following formats
43- * // 'devDisabledIn${productFlavor}${buildType}'
44- * // 'devDisabledIn${buildType}'
45- *
46- * // the root of your project, i.e. where "package.json" lives
47- * root: "../../",
48- *
49- * // where to put the JS bundle asset in debug mode
50- * jsBundleDirDebug: "$buildDir/intermediates/assets/debug",
51- *
52- * // where to put the JS bundle asset in release mode
53- * jsBundleDirRelease: "$buildDir/intermediates/assets/release",
54- *
55- * // where to put drawable resources / React Native assets, e.g. the ones you use via
56- * // require('./image.png')), in debug mode
57- * resourcesDirDebug: "$buildDir/intermediates/res/merged/debug",
58- *
59- * // where to put drawable resources / React Native assets, e.g. the ones you use via
60- * // require('./image.png')), in release mode
61- * resourcesDirRelease: "$buildDir/intermediates/res/merged/release",
62- *
63- * // by default the gradle tasks are skipped if none of the JS files or assets change; this means
64- * // that we don't look at files in android/ or ios/ to determine whether the tasks are up to
65- * // date; if you have any other folders that you want to ignore for performance reasons (gradle
66- * // indexes the entire tree), add them here. Alternatively, if you have JS files in android/
67- * // for MultipleImagePickerExample, you might want to remove it from here.
68- * inputExcludes: ["android/**", "ios/**"],
69- *
70- * // override which node gets called and with what additional arguments
71- * nodeExecutableAndArgs: ["node"],
72- *
73- * // supply additional arguments to the packager
74- * extraPackagerArgs: []
75- * ]
76- */
77-
78- project. ext. react = [
79- enableHermes : false , // clean and rebuild if changing
80- entryFile : " index.tsx" ,
81- ]
82-
83- apply from : " ../../node_modules/react-native/react.gradle"
84-
85- /**
86- * Set this to true to create two separate APKs instead of one:
87- * - An APK that only works on ARM devices
88- * - An APK that only works on x86 devices
89- * The advantage is the size of the APK is reduced by about 4MB.
90- * Upload all the APKs to the Play Store and people will download
91- * the correct one based on the CPU architecture of their device.
92- */
93- def enableSeparateBuildPerCPUArchitecture = false
946
95- /**
96- * Run Proguard to shrink the Java bytecode in release builds .
7+ * This is the configuration block to customize your React Native Android app.
8+ * By default you don't need to apply any configuration, just uncomment the lines you need .
979 */
98- def enableProguardInReleaseBuilds = false
99-
10+ react {
11+ /* Folders */
12+ // The root of your project, i.e. where "package.json" lives. Default is '..'
13+ // root = file("../")
14+ // The folder where the react-native NPM package is. Default is ../node_modules/react-native
15+ // reactNativeDir = file("../node_modules/react-native")
16+ // The folder where the react-native Codegen package is. Default is ../node_modules/react-native-codegen
17+ // codegenDir = file("../node_modules/react-native-codegen")
18+ // The cli.js file which is the React Native CLI entrypoint. Default is ../node_modules/react-native/cli.js
19+ // cliFile = file("../node_modules/react-native/cli.js")
20+ /* Variants */
21+ // The list of variants to that are debuggable. For those we're going to
22+ // skip the bundling of the JS bundle and the assets. By default is just 'debug'.
23+ // If you add flavors like lite, prod, etc. you'll have to list your debuggableVariants.
24+ // debuggableVariants = ["liteDebug", "prodDebug"]
25+ /* Bundling */
26+ // A list containing the node command and its flags. Default is just 'node'.
27+ // nodeExecutableAndArgs = ["node"]
28+ //
29+ // The command to run when bundling. By default is 'bundle'
30+ // bundleCommand = "ram-bundle"
31+ //
32+ // The path to the CLI configuration file. Default is empty.
33+ // bundleConfig = file(../rn-cli.config.js)
34+ //
35+ // The name of the generated asset file containing your JS bundle
36+ // bundleAssetName = "MyApplication.android.bundle"
37+ //
38+ // The entry file for bundle generation. Default is 'index.android.js' or 'index.js'
39+ // entryFile = file("../js/MyApplication.android.js")
40+ //
41+ // A list of extra flags to pass to the 'bundle' commands.
42+ // See https://github.com/react-native-community/cli/blob/main/docs/commands.md#bundle
43+ // extraPackagerArgs = []
44+ /* Hermes Commands */
45+ // The hermes compiler command to run. By default it is 'hermesc'
46+ // hermesCommand = "$rootDir/my-custom-hermesc/bin/hermesc"
47+ //
48+ // The list of flags to pass to the Hermes compiler. By default is "-O", "-output-source-map"
49+ // hermesFlags = ["-O", "-output-source-map"]
50+ }
10051/**
101- * The preferred build flavor of JavaScriptCore.
102- *
103- * For MultipleImagePickerExample, 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:+'
52+ def enableSeparateBuildPerCPUArchitecture = false
11253
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.
54+ * Private function to get the list of Native Architectures you want to build.
55+ * This reads the value from reactNativeArchitectures in your gradle.properties
56+ * file and works together with the --active-arch-only flag of react-native run-android.
11957 */
120- def enableHermes = project. ext. react. get(" enableHermes" , false );
58+ def reactNativeArchitectures () {
59+ def value = project. getProperties(). get(" reactNativeArchitectures" )
60+ return value ? value. split(" ," ) : [" armeabi-v7a" , " x86" , " x86_64" , " arm64-v8a" ]
61+ }
12162
12263android {
64+ ndkVersion rootProject. ext. ndkVersion
12365 compileSdkVersion rootProject. ext. compileSdkVersion
124-
125- compileOptions {
126- sourceCompatibility JavaVersion . VERSION_1_8
127- targetCompatibility JavaVersion . VERSION_1_8
128- }
66+ namespace " com.example.reactnativemultipleimagepicker"
12967
13068 defaultConfig {
13169 applicationId " com.example.reactnativemultipleimagepicker"
@@ -139,7 +77,7 @@ android {
13977 reset()
14078 enable enableSeparateBuildPerCPUArchitecture
14179 universalApk false // If true, also generate a universal APK
142- include " armeabi-v7a " , " x86 " , " arm64-v8a " , " x86_64 "
80+ include ( * reactNativeArchitectures())
14381 }
14482 }
14583 signingConfigs {
@@ -171,37 +109,28 @@ android {
171109 def abi = output. getFilter(OutputFile . ABI )
172110 if (abi != null ) { // null for the universal-debug, universal-release variants
173111 output. versionCodeOverride =
174- versionCodes . get(abi) * 1048576 + defaultConfig . versionCode
112+ defaultConfig . versionCode * 1000 + versionCodes . get(abi)
175113 }
176114
177115 }
178116 }
179117}
180118
181119dependencies {
182- implementation fileTree(dir : " libs" , include : [" *.jar" ])
183- // noinspection GradleDynamicVersion
184- implementation " com.facebook.react:react-native:+" // From node_modules
185-
120+ // The version of react-native is set by the React Native Gradle Plugin
121+ implementation(" com.facebook.react:react-android" )
186122
187- implementation " androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
188- debugImplementation(" com.facebook.flipper:flipper:${ FLIPPER_VERSION} " ) {
189- exclude group :' com.facebook.fbjni'
190- }
123+ implementation(" androidx.swiperefreshlayout:swiperefreshlayout:1.0.0" )
191124
125+ debugImplementation(" com.facebook.flipper:flipper:${ FLIPPER_VERSION} " )
192126 debugImplementation(" com.facebook.flipper:flipper-network-plugin:${ FLIPPER_VERSION} " ) {
193- exclude group :' com.facebook.flipper'
194127 exclude group :' com.squareup.okhttp3' , module :' okhttp'
195128 }
196129
197- debugImplementation(" com.facebook.flipper:flipper-fresco-plugin:${ FLIPPER_VERSION} " ) {
198- exclude group :' com.facebook.flipper'
199- }
200-
201- if (enableHermes) {
202- def hermesPath = " ../../node_modules/hermes-engine/android/" ;
203- debugImplementation files(hermesPath + " hermes-debug.aar" )
204- releaseImplementation files(hermesPath + " hermes-release.aar" )
130+ debugImplementation(" com.facebook.flipper:flipper-fresco-plugin:${ FLIPPER_VERSION} " )
131+
132+ if (hermesEnabled. toBoolean()) {
133+ implementation(" com.facebook.react:hermes-android" )
205134 } else {
206135 implementation jscFlavor
207136 }
0 commit comments