build.gradle 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. import groovy.json.JsonSlurper
  2. apply plugin: "com.android.application"
  3. apply plugin: "org.jetbrains.kotlin.android"
  4. apply plugin: "com.facebook.react"
  5. /**
  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.
  8. */
  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. /* Variants */
  20. // The list of variants to that are debuggable. For those we're going to
  21. // skip the bundling of the JS bundle and the assets. By default is just 'debug'.
  22. // If you add flavors like lite, prod, etc. you'll have to list your debuggableVariants.
  23. // debuggableVariants = ["liteDebug", "prodDebug"]
  24. /* Bundling */
  25. // A list containing the node command and its flags. Default is just 'node'.
  26. // nodeExecutableAndArgs = ["node"]
  27. //
  28. // The command to run when bundling. By default is 'bundle'
  29. // bundleCommand = "ram-bundle"
  30. //
  31. // The path to the CLI configuration file. Default is empty.
  32. // bundleConfig = file(../rn-cli.config.js)
  33. //
  34. // The name of the generated asset file containing your JS bundle
  35. // bundleAssetName = "MyApplication.android.bundle"
  36. //
  37. // The entry file for bundle generation. Default is 'index.android.js' or 'index.js'
  38. // entryFile = file("../js/MyApplication.android.js")
  39. //
  40. // A list of extra flags to pass to the 'bundle' commands.
  41. // See https://github.com/react-native-community/cli/blob/main/docs/commands.md#bundle
  42. // extraPackagerArgs = []
  43. /* Hermes Commands */
  44. // The hermes compiler command to run. By default it is 'hermesc'
  45. // hermesCommand = "$rootDir/my-custom-hermesc/bin/hermesc"
  46. //
  47. // The list of flags to pass to the Hermes compiler. By default is "-O", "-output-source-map"
  48. // hermesFlags = ["-O", "-output-source-map"]
  49. }
  50. /**
  51. * Set this to true to Run Proguard on Release builds to minify the Java bytecode.
  52. */
  53. def enableProguardInReleaseBuilds = false
  54. /**
  55. * The preferred build flavor of JavaScriptCore (JSC)
  56. *
  57. * For example, to use the international variant, you can use:
  58. * `def jscFlavor = 'org.webkit:android-jsc-intl:+'`
  59. *
  60. * The international variant includes ICU i18n library and necessary data
  61. * allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that
  62. * give correct results when using with locales other than en-US. Note that
  63. * this variant is about 6MiB larger per architecture than default.
  64. */
  65. def jscFlavor = 'org.webkit:android-jsc:+'
  66. def getAppVersionName() {
  67. def inputFile = new File("../package.json")
  68. def packageJson = new JsonSlurper().parseText(inputFile.text)
  69. return packageJson["version"]
  70. }
  71. def getAppVersionCode() {
  72. def inputFile = new File("../package.json")
  73. def packageJson = new JsonSlurper().parseText(inputFile.text)
  74. return packageJson["versionCode"] as int
  75. }
  76. def appVersionName = getAppVersionName()
  77. def appVersionCode = getAppVersionCode()
  78. android {
  79. ndkVersion rootProject.ext.ndkVersion
  80. buildToolsVersion rootProject.ext.buildToolsVersion
  81. compileSdk rootProject.ext.compileSdkVersion
  82. namespace "com.compdfkit.reactnative.example"
  83. defaultConfig {
  84. applicationId "com.compdfkit.reactnative.example"
  85. minSdkVersion rootProject.ext.minSdkVersion
  86. targetSdkVersion rootProject.ext.targetSdkVersion
  87. versionCode appVersionCode
  88. versionName appVersionName
  89. }
  90. signingConfigs {
  91. debug {
  92. storeFile file('debug.keystore')
  93. storePassword 'android'
  94. keyAlias 'androiddebugkey'
  95. keyPassword 'android'
  96. }
  97. }
  98. buildTypes {
  99. debug {
  100. signingConfig signingConfigs.debug
  101. }
  102. release {
  103. // Caution! In production, you need to generate your own keystore file.
  104. // see https://reactnative.dev/docs/signed-apk-android.
  105. signingConfig signingConfigs.debug
  106. minifyEnabled enableProguardInReleaseBuilds
  107. proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
  108. }
  109. }
  110. }
  111. dependencies {
  112. implementation fileTree(include: ['*.jar','*.aar'], dir: 'libs')
  113. // The version of react-native is set by the React Native Gradle Plugin
  114. implementation("com.facebook.react:react-android")
  115. implementation 'com.google.android.material:material:1.8.0'
  116. if (hermesEnabled.toBoolean()) {
  117. implementation("com.facebook.react:hermes-android")
  118. } else {
  119. implementation jscFlavor
  120. }
  121. }
  122. apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)