build.gradle 7.5 KB

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