build.gradle 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. apply plugin: "com.android.application"
  2. apply from: project(':react-native-config').projectDir.getPath() + "/dotenv.gradle"
  3. apply plugin: 'com.google.gms.google-services'
  4. import com.android.build.OutputFile
  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. project.ext.react = [
  80. enableHermes: (findProperty('expo.jsEngine') ?: "jsc") == "hermes",
  81. cliPath: new File(["node", "--print", "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim()).getParentFile().getAbsolutePath() + "/cli.js",
  82. hermesCommand: new File(["node", "--print", "require.resolve('hermes-engine/package.json')"].execute(null, rootDir).text.trim()).getParentFile().getAbsolutePath() + "/%OS-BIN%/hermesc",
  83. composeSourceMapsPath: new File(["node", "--print", "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim()).getParentFile().getAbsolutePath() + "/scripts/compose-source-maps.js",
  84. ]
  85. apply from: new File(["node", "--print", "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim(), "../react.gradle")
  86. /**
  87. * Set this to true to create two separate APKs instead of one:
  88. * - An APK that only works on ARM devices
  89. * - An APK that only works on x86 devices
  90. * The advantage is the size of the APK is reduced by about 4MB.
  91. * Upload all the APKs to the Play Store and people will download
  92. * the correct one based on the CPU architecture of their device.
  93. */
  94. def enableSeparateBuildPerCPUArchitecture = false
  95. /**
  96. * Run Proguard to shrink the Java bytecode in release builds.
  97. */
  98. def enableProguardInReleaseBuilds = false
  99. /**
  100. * The preferred build flavor of JavaScriptCore.
  101. *
  102. * For example, to use the international variant, you can use:
  103. * `def jscFlavor = 'org.webkit:android-jsc-intl:+'`
  104. *
  105. * The international variant includes ICU i18n library and necessary data
  106. * allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that
  107. * give correct results when using with locales other than en-US. Note that
  108. * this variant is about 6MiB larger per architecture than default.
  109. */
  110. def jscFlavor = 'org.webkit:android-jsc:+'
  111. /**
  112. * Whether to enable the Hermes VM.
  113. *
  114. * This should be set on project.ext.react and mirrored here. If it is not set
  115. * on project.ext.react, JavaScript will not be compiled to Hermes Bytecode
  116. * and the benefits of using Hermes will therefore be sharply reduced.
  117. */
  118. def enableHermes = project.ext.react.get("enableHermes", false);
  119. android {
  120. compileSdkVersion rootProject.ext.compileSdkVersion
  121. compileOptions {
  122. sourceCompatibility JavaVersion.VERSION_1_8
  123. targetCompatibility JavaVersion.VERSION_1_8
  124. }
  125. defaultConfig {
  126. manifestPlaceholders = [
  127. appAuthRedirectScheme: 'cnp.mobile'
  128. ]
  129. applicationId 'com.clicknpush.mobile'
  130. minSdkVersion rootProject.ext.minSdkVersion
  131. targetSdkVersion rootProject.ext.targetSdkVersion
  132. versionCode 28
  133. versionName "0.1.8"
  134. }
  135. splits {
  136. abi {
  137. reset()
  138. enable enableSeparateBuildPerCPUArchitecture
  139. universalApk false // If true, also generate a universal APK
  140. include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
  141. }
  142. }
  143. signingConfigs {
  144. debug {
  145. storeFile file('debug.keystore')
  146. storePassword 'android'
  147. keyAlias 'androiddebugkey'
  148. keyPassword 'android'
  149. }
  150. release {
  151. storeFile file('cnp-mobile.jks')
  152. storePassword 'fef58ba01a1d4fd2a36783cc60ef70f9'
  153. keyAlias 'QGNkbW9zcy9jbnAtbW9iaWxl'
  154. keyPassword 'b16103372fd240afa9c0b0445d0677c3'
  155. }
  156. }
  157. buildTypes {
  158. debug {
  159. signingConfig signingConfigs.debug
  160. }
  161. release {
  162. // Caution! In production, you need to generate your own keystore file.
  163. // see https://reactnative.dev/docs/signed-apk-android.
  164. signingConfig signingConfigs.release
  165. minifyEnabled enableProguardInReleaseBuilds
  166. proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
  167. }
  168. }
  169. // applicationVariants are e.g. debug, release
  170. applicationVariants.all { variant ->
  171. variant.outputs.each { output ->
  172. // For each separate APK per architecture, set a unique version code as described here:
  173. // https://developer.android.com/studio/build/configure-apk-splits.html
  174. def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4]
  175. def abi = output.getFilter(OutputFile.ABI)
  176. if (abi != null) { // null for the universal-debug, universal-release variants
  177. output.versionCodeOverride =
  178. versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
  179. }
  180. }
  181. }
  182. }
  183. dependencies {
  184. implementation fileTree(dir: "libs", include: ["*.jar"])
  185. //noinspection GradleDynamicVersion
  186. implementation "com.facebook.react:react-native:+" // From node_modules
  187. implementation project(':react-native-config');
  188. def isGifEnabled = (findProperty('expo.gif.enabled') ?: "") == "true";
  189. def isWebpEnabled = (findProperty('expo.webp.enabled') ?: "") == "true";
  190. def isWebpAnimatedEnabled = (findProperty('expo.webp.animated') ?: "") == "true";
  191. // If your app supports Android versions before Ice Cream Sandwich (API level 14)
  192. // All fresco packages should use the same version
  193. if (isGifEnabled || isWebpEnabled) {
  194. implementation 'com.facebook.fresco:fresco:2.0.0'
  195. implementation 'com.facebook.fresco:imagepipeline-okhttp3:2.0.0'
  196. }
  197. if (isGifEnabled) {
  198. // For animated gif support
  199. implementation 'com.facebook.fresco:animated-gif:2.0.0'
  200. }
  201. if (isWebpEnabled) {
  202. // For webp support
  203. implementation 'com.facebook.fresco:webpsupport:2.0.0'
  204. if (isWebpAnimatedEnabled) {
  205. // Animated webp support
  206. implementation 'com.facebook.fresco:animated-webp:2.0.0'
  207. }
  208. }
  209. implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
  210. debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") {
  211. exclude group:'com.facebook.fbjni'
  212. }
  213. debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
  214. exclude group:'com.facebook.flipper'
  215. exclude group:'com.squareup.okhttp3', module:'okhttp'
  216. }
  217. debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") {
  218. exclude group:'com.facebook.flipper'
  219. }
  220. if (enableHermes) {
  221. debugImplementation files(new File(["node", "--print", "require.resolve('hermes-engine/package.json')"].execute(null, rootDir).text.trim(), "../android/hermes-debug.aar"))
  222. releaseImplementation files(new File(["node", "--print", "require.resolve('hermes-engine/package.json')"].execute(null, rootDir).text.trim(), "../android/hermes-release.aar"))
  223. } else {
  224. implementation jscFlavor
  225. }
  226. }
  227. // Run this once to be able to run the application with BUCK
  228. // puts all compile dependencies into folder libs for BUCK to use
  229. task copyDownloadableDepsToLibs(type: Copy) {
  230. from configurations.compile
  231. into 'libs'
  232. }
  233. apply from: new File(["node", "--print", "require.resolve('@react-native-community/cli-platform-android/package.json')"].execute(null, rootDir).text.trim(), "../native_modules.gradle");
  234. applyNativeModulesAppBuildGradle(project)