build.gradle 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. apply plugin: "com.android.application"
  2. apply plugin: "org.jetbrains.kotlin.android"
  3. apply plugin: "com.facebook.react"
  4. def projectRoot = rootDir.getAbsoluteFile().getParentFile().getAbsolutePath()
  5. /**
  6. * Run Proguard to shrink the Java bytecode in release builds.
  7. */
  8. def enableProguardInReleaseBuilds = true
  9. /**
  10. * This is the configuration block to customize your React Native Android app.
  11. * By default you don't need to apply any configuration, just uncomment the lines you need.
  12. */
  13. react {
  14. entryFile = file(["node", "-e", "require('expo/scripts/resolveAppEntry')", projectRoot, "android", "absolute"].execute(null, rootDir).text.trim())
  15. reactNativeDir = new File(["node", "--print", "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim()).getParentFile().getAbsoluteFile()
  16. hermesCommand = new File(["node", "--print", "require.resolve('hermes-compiler/package.json', { paths: [require.resolve('react-native/package.json')] })"].execute(null, rootDir).text.trim()).getParentFile().getAbsolutePath() + "/hermesc/%OS-BIN%/hermesc"
  17. codegenDir = new File(["node", "--print", "require.resolve('@react-native/codegen/package.json', { paths: [require.resolve('react-native/package.json')] })"].execute(null, rootDir).text.trim()).getParentFile().getAbsoluteFile()
  18. enableBundleCompression = (findProperty('android.enableBundleCompression') ?: false).toBoolean()
  19. // Use Expo CLI to bundle the app, this ensures the Metro config
  20. // works correctly with Expo projects.
  21. cliFile = new File(["node", "--print", "require.resolve('@expo/cli', { paths: [require.resolve('expo/package.json')] })"].execute(null, rootDir).text.trim())
  22. bundleCommand = "export:embed"
  23. /* Folders */
  24. // The root of your project, i.e. where "package.json" lives. Default is '../..'
  25. // root = file("../../")
  26. // The folder where the react-native NPM package is. Default is ../../node_modules/react-native
  27. // reactNativeDir = file("../../node_modules/react-native")
  28. // The folder where the react-native Codegen package is. Default is ../../node_modules/@react-native/codegen
  29. // codegenDir = file("../../node_modules/@react-native/codegen")
  30. /* Variants */
  31. // The list of variants to that are debuggable. For those we're going to
  32. // skip the bundling of the JS bundle and the assets. By default is just 'debug'.
  33. // If you add flavors like lite, prod, etc. you'll have to list your debuggableVariants.
  34. // debuggableVariants = ["liteDebug", "prodDebug"]
  35. /* Bundling */
  36. // A list containing the node command and its flags. Default is just 'node'.
  37. // nodeExecutableAndArgs = ["node"]
  38. //
  39. // The path to the CLI configuration file. Default is empty.
  40. // bundleConfig = file(../rn-cli.config.js)
  41. //
  42. // The name of the generated asset file containing your JS bundle
  43. // bundleAssetName = "MyApplication.android.bundle"
  44. //
  45. // The entry file for bundle generation. Default is 'index.android.js' or 'index.js'
  46. // entryFile = file("../js/MyApplication.android.js")
  47. //
  48. // A list of extra flags to pass to the 'bundle' commands.
  49. // See https://github.com/react-native-community/cli/blob/main/docs/commands.md#bundle
  50. // extraPackagerArgs = []
  51. /* Hermes Commands */
  52. // The hermes compiler command to run. By default it is 'hermesc'
  53. // hermesCommand = "$rootDir/my-custom-hermesc/bin/hermesc"
  54. //
  55. // The list of flags to pass to the Hermes compiler. By default is "-O", "-output-source-map"
  56. // hermesFlags = ["-O", "-output-source-map"]
  57. /* Autolinking */
  58. autolinkLibrariesWithApp()
  59. }
  60. /**
  61. * Set this to true in release builds to optimize the app using [R8](https://developer.android.com/topic/performance/app-optimization/enable-app-optimization).
  62. */
  63. def enableMinifyInReleaseBuilds = (findProperty('android.enableMinifyInReleaseBuilds') ?: false).toBoolean()
  64. /**
  65. * The preferred build flavor of JavaScriptCore (JSC)
  66. *
  67. * For example, to use the international variant, you can use:
  68. * `def jscFlavor = 'org.webkit:android-jsc-intl:+'`
  69. *
  70. * The international variant includes ICU i18n library and necessary data
  71. * allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that
  72. * give correct results when using with locales other than en-US. Note that
  73. * this variant is about 6MiB larger per architecture than default.
  74. */
  75. def jscFlavor = 'io.github.react-native-community:jsc-android:2026004.+'
  76. android {
  77. ndkVersion rootProject.ext.ndkVersion
  78. buildToolsVersion rootProject.ext.buildToolsVersion
  79. compileSdk rootProject.ext.compileSdkVersion
  80. namespace 'com.cdloan.assistant'
  81. defaultConfig {
  82. applicationId 'com.cdloan.assistant'
  83. minSdkVersion rootProject.ext.minSdkVersion
  84. targetSdkVersion rootProject.ext.targetSdkVersion
  85. versionCode 1
  86. versionName "1.0.1"
  87. buildConfigField "String", "REACT_NATIVE_RELEASE_LEVEL", "\"${findProperty('reactNativeReleaseLevel') ?: 'stable'}\""
  88. }
  89. signingConfigs {
  90. debug {
  91. storeFile file('debug.keystore')
  92. storePassword 'android'
  93. keyAlias 'androiddebugkey'
  94. keyPassword 'android'
  95. }
  96. }
  97. buildTypes {
  98. debug {
  99. signingConfig signingConfigs.debug
  100. }
  101. release {
  102. // Caution! In production, you need to generate your own keystore file.
  103. // see https://reactnative.dev/docs/signed-apk-android.
  104. signingConfig signingConfigs.debug
  105. def enableShrinkResources = findProperty('android.enableShrinkResourcesInReleaseBuilds') ?: 'false'
  106. shrinkResources enableShrinkResources.toBoolean()
  107. minifyEnabled enableMinifyInReleaseBuilds
  108. proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
  109. def enablePngCrunchInRelease = findProperty('android.enablePngCrunchInReleaseBuilds') ?: 'true'
  110. crunchPngs enablePngCrunchInRelease.toBoolean()
  111. }
  112. }
  113. packagingOptions {
  114. jniLibs {
  115. def enableLegacyPackaging = findProperty('expo.useLegacyPackaging') ?: 'false'
  116. useLegacyPackaging enableLegacyPackaging.toBoolean()
  117. }
  118. }
  119. androidResources {
  120. ignoreAssetsPattern '!.svn:!.git:!.ds_store:!*.scc:!CVS:!thumbs.db:!picasa.ini:!*~'
  121. }
  122. }
  123. // Apply static values from `gradle.properties` to the `android.packagingOptions`
  124. // Accepts values in comma delimited lists, example:
  125. // android.packagingOptions.pickFirsts=/LICENSE,**/picasa.ini
  126. ["pickFirsts", "excludes", "merges", "doNotStrip"].each { prop ->
  127. // Split option: 'foo,bar' -> ['foo', 'bar']
  128. def options = (findProperty("android.packagingOptions.$prop") ?: "").split(",");
  129. // Trim all elements in place.
  130. for (i in 0..<options.size()) options[i] = options[i].trim();
  131. // `[] - ""` is essentially `[""].filter(Boolean)` removing all empty strings.
  132. options -= ""
  133. if (options.length > 0) {
  134. println "android.packagingOptions.$prop += $options ($options.length)"
  135. // Ex: android.packagingOptions.pickFirsts += '**/SCCS/**'
  136. options.each {
  137. android.packagingOptions[prop] += it
  138. }
  139. }
  140. }
  141. dependencies {
  142. // The version of react-native is set by the React Native Gradle Plugin
  143. implementation("com.facebook.react:react-android")
  144. def isGifEnabled = (findProperty('expo.gif.enabled') ?: "") == "true";
  145. def isWebpEnabled = (findProperty('expo.webp.enabled') ?: "") == "true";
  146. def isWebpAnimatedEnabled = (findProperty('expo.webp.animated') ?: "") == "true";
  147. if (isGifEnabled) {
  148. // For animated gif support
  149. implementation("com.facebook.fresco:animated-gif:${expoLibs.versions.fresco.get()}")
  150. }
  151. if (isWebpEnabled) {
  152. // For webp support
  153. implementation("com.facebook.fresco:webpsupport:${expoLibs.versions.fresco.get()}")
  154. if (isWebpAnimatedEnabled) {
  155. // Animated webp support
  156. implementation("com.facebook.fresco:animated-webp:${expoLibs.versions.fresco.get()}")
  157. }
  158. }
  159. if (hermesEnabled.toBoolean()) {
  160. implementation("com.facebook.react:hermes-android")
  161. } else {
  162. implementation jscFlavor
  163. }
  164. }