11apply plugin : " com.android.application"
2-
3- import com.android.build.OutputFile
4-
5- /**
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. 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.
21- * entryFile: "index.android.js",
22- *
23- * // https://reactnative.dev/docs/performance#enable-the-ram-format
24- * bundleCommand: "ram-bundle",
25- *
26- * // whether to bundle JS and assets in debug mode
27- * bundleInDebug: false,
28- *
29- * // whether to bundle JS and assets in release mode
30- * bundleInRelease: true,
31- *
32- * // whether to bundle JS and assets in another build variant (if configured).
33- * // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants
34- * // The configuration property can be in the following formats
35- * // 'bundleIn${productFlavor}${buildType}'
36- * // 'bundleIn${buildType}'
37- * // bundleInFreeDebug: true,
38- * // bundleInPaidRelease: true,
39- * // bundleInBeta: true,
40- *
41- * // whether to disable dev mode in custom build variants (by default only disabled in release)
42- * // for example: to disable dev mode in the staging build type (if configured)
43- * devDisabledInStaging: true,
44- * // The configuration property can be in the following formats
45- * // 'devDisabledIn${productFlavor}${buildType}'
46- * // 'devDisabledIn${buildType}'
47- *
48- * // the root of your project, i.e. where "package.json" lives
49- * root: "../../",
50- *
51- * // where to put the JS bundle asset in debug mode
52- * jsBundleDirDebug: "$buildDir/intermediates/assets/debug",
53- *
54- * // where to put the JS bundle asset in release mode
55- * jsBundleDirRelease: "$buildDir/intermediates/assets/release",
56- *
57- * // where to put drawable resources / React Native assets, e.g. the ones you use via
58- * // require('./image.png')), in debug mode
59- * resourcesDirDebug: "$buildDir/intermediates/res/merged/debug",
60- *
61- * // where to put drawable resources / React Native assets, e.g. the ones you use via
62- * // require('./image.png')), in release mode
63- * resourcesDirRelease: "$buildDir/intermediates/res/merged/release",
64- *
65- * // by default the gradle tasks are skipped if none of the JS files or assets change; this means
66- * // that we don't look at files in android/ or ios/ to determine whether the tasks are up to
67- * // date; if you have any other folders that you want to ignore for performance reasons (gradle
68- * // indexes the entire tree), add them here. Alternatively, if you have JS files in android/
69- * // for example, you might want to remove it from here.
70- * inputExcludes: ["android/**", "ios/**"],
71- *
72- * // override which node gets called and with what additional arguments
73- * nodeExecutableAndArgs: ["node"],
74- *
75- * // supply additional arguments to the packager
76- * extraPackagerArgs: []
77- * ]
78- */
79-
80- project. ext. react = [
81- enableHermes : true , // clean and rebuild if changing
82- entryFile : " index.tsx" ,
83- ]
84-
85- apply from : " ../../node_modules/react-native/react.gradle"
2+ apply plugin : " org.jetbrains.kotlin.android"
3+ apply plugin : " com.facebook.react"
864
875/**
88- * Set this to true to create two separate APKs instead of one:
89- * - An APK that only works on ARM devices
90- * - An APK that only works on x86 devices
91- * The advantage is the size of the APK is reduced by about 4MB.
92- * Upload all the APKs to the Play Store and people will download
93- * the correct one based on the CPU architecture of their device.
6+ * This is the configuration block to customize your React Native Android app.
7+ * By default you don't need to apply any configuration, just uncomment the lines you need.
948 */
95- def enableSeparateBuildPerCPUArchitecture = false
9+ react {
10+ /* Folders */
11+ // The root of your project, i.e. where "package.json" lives. Default is '../..'
12+ // root = file("../../")
13+ // The folder where the react-native NPM package is. Default is ../../node_modules/react-native
14+ // reactNativeDir = file("../../node_modules/react-native")
15+ // The folder where the react-native Codegen package is. Default is ../../node_modules/@react-native/codegen
16+ // codegenDir = file("../../node_modules/@react-native/codegen")
17+ // The cli.js file which is the React Native CLI entrypoint. Default is ../../node_modules/react-native/cli.js
18+ // cliFile = file("../../node_modules/react-native/cli.js")
19+
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+
26+ /* Bundling */
27+ // A list containing the node command and its flags. Default is just 'node'.
28+ // nodeExecutableAndArgs = ["node"]
29+ //
30+ // The command to run when bundling. By default is 'bundle'
31+ // bundleCommand = "ram-bundle"
32+ //
33+ // The path to the CLI configuration file. Default is empty.
34+ // bundleConfig = file(../rn-cli.config.js)
35+ //
36+ // The name of the generated asset file containing your JS bundle
37+ // bundleAssetName = "MyApplication.android.bundle"
38+ //
39+ // The entry file for bundle generation. Default is 'index.android.js' or 'index.js'
40+ // entryFile = file("../js/MyApplication.android.js")
41+ //
42+ // A list of extra flags to pass to the 'bundle' commands.
43+ // See https://github.com/react-native-community/cli/blob/main/docs/commands.md#bundle
44+ // extraPackagerArgs = []
45+
46+ /* Hermes Commands */
47+ // The hermes compiler command to run. By default it is 'hermesc'
48+ // hermesCommand = "$rootDir/my-custom-hermesc/bin/hermesc"
49+ //
50+ // The list of flags to pass to the Hermes compiler. By default is "-O", "-output-source-map"
51+ // hermesFlags = ["-O", "-output-source-map"]
52+ /* Autolinking */
53+ autolinkLibrariesWithApp()
54+ }
9655
9756/**
98- * Run Proguard to shrink the Java bytecode in release builds .
57+ * Set this to true to Run Proguard on Release builds to minify the Java bytecode.
9958 */
10059def enableProguardInReleaseBuilds = false
10160
10261/**
103- * The preferred build flavor of JavaScriptCore.
62+ * The preferred build flavor of JavaScriptCore (JSC)
10463 *
10564 * For example, to use the international variant, you can use:
10665 * `def jscFlavor = 'org.webkit:android-jsc-intl:+'`
10766 *
10867 * The international variant includes ICU i18n library and necessary data
10968 * allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that
110- * give correct results when using with locales other than en-US. Note that
69+ * give correct results when using with locales other than en-US. Note that
11170 * this variant is about 6MiB larger per architecture than default.
11271 */
11372def jscFlavor = ' org.webkit:android-jsc:+'
11473
115- /**
116- * Whether to enable the Hermes VM.
117- *
118- * This should be set on project.ext.react and that value will be read here. If it is not set
119- * on project.ext.react, JavaScript will not be compiled to Hermes Bytecode
120- * and the benefits of using Hermes will therefore be sharply reduced.
121- */
122- def enableHermes = project. ext. react. get(" enableHermes" , false );
123-
124- /**
125- * Architectures to build native code for in debug.
126- */
127- def nativeArchitectures = project. getProperties(). get(" reactNativeDebugArchitectures" )
128-
12974android {
13075 ndkVersion rootProject. ext. ndkVersion
76+ buildToolsVersion rootProject. ext. buildToolsVersion
77+ compileSdk rootProject. ext. compileSdkVersion
13178
132- compileSdkVersion rootProject. ext. compileSdkVersion
133-
79+ namespace " com.example.reactnativepdfviewer"
13480 defaultConfig {
13581 applicationId " com.example.reactnativepdfviewer"
13682 minSdkVersion rootProject. ext. minSdkVersion
13783 targetSdkVersion rootProject. ext. targetSdkVersion
13884 versionCode 1
13985 versionName " 1.0"
14086 }
141- splits {
142- abi {
143- reset()
144- enable enableSeparateBuildPerCPUArchitecture
145- universalApk false // If true, also generate a universal APK
146- include " armeabi-v7a" , " x86" , " arm64-v8a" , " x86_64"
147- }
148- }
14987 signingConfigs {
15088 debug {
15189 storeFile file(' debug.keystore' )
@@ -157,11 +95,6 @@ android {
15795 buildTypes {
15896 debug {
15997 signingConfig signingConfigs. debug
160- if (nativeArchitectures) {
161- ndk {
162- abiFilters nativeArchitectures. split(' ,' )
163- }
164- }
16598 }
16699 release {
167100 // Caution! In production, you need to generate your own keystore file.
@@ -171,57 +104,15 @@ android {
171104 proguardFiles getDefaultProguardFile(" proguard-android.txt" ), " proguard-rules.pro"
172105 }
173106 }
174- // applicationVariants are e.g. debug, release
175- applicationVariants. all { variant ->
176- variant. outputs. each { output ->
177- // For each separate APK per architecture, set a unique version code as described here:
178- // https://developer.android.com/studio/build/configure-apk-splits.html
179- // Example: versionCode 1 will generate 1001 for armeabi-v7a, 1002 for x86, etc.
180- def versionCodes = [" armeabi-v7a" : 1 , " x86" : 2 , " arm64-v8a" : 3 , " x86_64" : 4 ]
181- def abi = output. getFilter(OutputFile . ABI )
182- if (abi != null ) { // null for the universal-debug, universal-release variants
183- output. versionCodeOverride =
184- defaultConfig. versionCode * 1000 + versionCodes. get(abi)
185- }
186-
187- }
188- }
189107}
190108
191109dependencies {
192- implementation fileTree(dir : " libs" , include : [" *.jar" ])
193- // noinspection GradleDynamicVersion
194- implementation " com.facebook.react:react-native:+" // From node_modules
195-
110+ // The version of react-native is set by the React Native Gradle Plugin
111+ implementation(" com.facebook.react:react-android" )
196112
197- implementation " androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
198- debugImplementation(" com.facebook.flipper:flipper:${ FLIPPER_VERSION} " ) {
199- exclude group :' com.facebook.fbjni'
200- }
201- debugImplementation(" com.facebook.flipper:flipper-network-plugin:${ FLIPPER_VERSION} " ) {
202- exclude group :' com.facebook.flipper'
203- exclude group :' com.squareup.okhttp3' , module :' okhttp'
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" )
113+ if (hermesEnabled. toBoolean()) {
114+ implementation(" com.facebook.react:hermes-android" )
213115 } else {
214116 implementation jscFlavor
215117 }
216-
217- implementation project(' :reactnativepdfview' )
218118}
219-
220- // Run this once to be able to run the application with BUCK
221- // puts all compile dependencies into folder libs for BUCK to use
222- task copyDownloadableDepsToLibs (type : Copy ) {
223- from configurations. implementation
224- into ' libs'
225- }
226-
227- apply from : file(" ../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle" ); applyNativeModulesAppBuildGradle(project)
0 commit comments