You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

251 line
9.3 KiB

  1. apply plugin: "com.android.application"
  2. import com.android.build.OutputFile
  3. /**
  4. * The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets
  5. * and bundleReleaseJsAndAssets).
  6. * These basically call `react-native bundle` with the correct arguments during the Android build
  7. * cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the
  8. * bundle directly from the development server. Below you can see all the possible configurations
  9. * and their defaults. If you decide to add a configuration block, make sure to add it before the
  10. * `apply from: "../../node_modules/react-native/react.gradle"` line.
  11. *
  12. * project.ext.react = [
  13. * // the name of the generated asset file containing your JS bundle
  14. * bundleAssetName: "index.android.bundle",
  15. *
  16. * // the entry file for bundle generation. If none specified and
  17. * // "index.android.js" exists, it will be used. Otherwise "index.js" is
  18. * // default. Can be overridden with ENTRY_FILE environment variable.
  19. * entryFile: "index.android.js",
  20. *
  21. * // https://facebook.github.io/react-native/docs/performance#enable-the-ram-format
  22. * bundleCommand: "ram-bundle",
  23. *
  24. * // whether to bundle JS and assets in debug mode
  25. * bundleInDebug: false,
  26. *
  27. * // whether to bundle JS and assets in release mode
  28. * bundleInRelease: true,
  29. *
  30. * // whether to bundle JS and assets in another build variant (if configured).
  31. * // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants
  32. * // The configuration property can be in the following formats
  33. * // 'bundleIn${productFlavor}${buildType}'
  34. * // 'bundleIn${buildType}'
  35. * // bundleInFreeDebug: true,
  36. * // bundleInPaidRelease: true,
  37. * // bundleInBeta: true,
  38. *
  39. * // whether to disable dev mode in custom build variants (by default only disabled in release)
  40. * // for example: to disable dev mode in the staging build type (if configured)
  41. * devDisabledInStaging: true,
  42. * // The configuration property can be in the following formats
  43. * // 'devDisabledIn${productFlavor}${buildType}'
  44. * // 'devDisabledIn${buildType}'
  45. *
  46. * // the root of your project, i.e. where "package.json" lives
  47. * root: "../../",
  48. *
  49. * // where to put the JS bundle asset in debug mode
  50. * jsBundleDirDebug: "$buildDir/intermediates/assets/debug",
  51. *
  52. * // where to put the JS bundle asset in release mode
  53. * jsBundleDirRelease: "$buildDir/intermediates/assets/release",
  54. *
  55. * // where to put drawable resources / React Native assets, e.g. the ones you use via
  56. * // require('./image.png')), in debug mode
  57. * resourcesDirDebug: "$buildDir/intermediates/res/merged/debug",
  58. *
  59. * // where to put drawable resources / React Native assets, e.g. the ones you use via
  60. * // require('./image.png')), in release mode
  61. * resourcesDirRelease: "$buildDir/intermediates/res/merged/release",
  62. *
  63. * // by default the gradle tasks are skipped if none of the JS files or assets change; this means
  64. * // that we don't look at files in android/ or ios/ to determine whether the tasks are up to
  65. * // date; if you have any other folders that you want to ignore for performance reasons (gradle
  66. * // indexes the entire tree), add them here. Alternatively, if you have JS files in android/
  67. * // for example, you might want to remove it from here.
  68. * inputExcludes: ["android/**", "ios/**"],
  69. *
  70. * // override which node gets called and with what additional arguments
  71. * nodeExecutableAndArgs: ["node"],
  72. *
  73. * // supply additional arguments to the packager
  74. * extraPackagerArgs: []
  75. * ]
  76. */
  77. project.ext.vectoricons = [
  78. iconFontNames: [
  79. "MaterialCommunityIcons.ttf",
  80. "FontAwesome.ttf"
  81. ]
  82. ]
  83. apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"
  84. project.ext.react = [
  85. enableHermes: false, // clean and rebuild if changing
  86. ]
  87. apply from: "../../node_modules/react-native/react.gradle"
  88. /**
  89. * Set this to true to create two separate APKs instead of one:
  90. * - An APK that only works on ARM devices
  91. * - An APK that only works on x86 devices
  92. * The advantage is the size of the APK is reduced by about 4MB.
  93. * Upload all the APKs to the Play Store and people will download
  94. * the correct one based on the CPU architecture of their device.
  95. */
  96. def enableSeparateBuildPerCPUArchitecture = true
  97. /**
  98. * Run Proguard to shrink the Java bytecode in release builds.
  99. */
  100. def enableProguardInReleaseBuilds = false
  101. /**
  102. * The preferred build flavor of JavaScriptCore.
  103. *
  104. * For example, to use the international variant, you can use:
  105. * `def jscFlavor = 'org.webkit:android-jsc-intl:+'`
  106. *
  107. * The international variant includes ICU i18n library and necessary data
  108. * allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that
  109. * give correct results when using with locales other than en-US. Note that
  110. * this variant is about 6MiB larger per architecture than default.
  111. */
  112. def jscFlavor = 'org.webkit:android-jsc:+'
  113. /**
  114. * Whether to enable the Hermes VM.
  115. *
  116. * This should be set on project.ext.react and mirrored here. If it is not set
  117. * on project.ext.react, JavaScript will not be compiled to Hermes Bytecode
  118. * and the benefits of using Hermes will therefore be sharply reduced.
  119. */
  120. def enableHermes = project.ext.react.get("enableHermes", false);
  121. android {
  122. compileSdkVersion rootProject.ext.compileSdkVersion
  123. compileOptions {
  124. sourceCompatibility JavaVersion.VERSION_1_8
  125. targetCompatibility JavaVersion.VERSION_1_8
  126. }
  127. defaultConfig {
  128. applicationId "com.lesspass.android"
  129. minSdkVersion rootProject.ext.minSdkVersion
  130. targetSdkVersion rootProject.ext.targetSdkVersion
  131. versionCode versionMajor * 10000 + versionMinor * 100 + versionPatch
  132. versionName "${versionMajor}.${versionMinor}.${versionPatch}"
  133. }
  134. signingConfigs {
  135. debug {
  136. storeFile file('debug.keystore')
  137. storePassword 'android'
  138. keyAlias 'androiddebugkey'
  139. keyPassword 'android'
  140. }
  141. release {
  142. if (project.hasProperty('LESSPASS_RELEASE_STORE_FILE')) {
  143. storeFile file(LESSPASS_RELEASE_STORE_FILE)
  144. storePassword LESSPASS_RELEASE_STORE_PASSWORD
  145. keyAlias LESSPASS_RELEASE_KEY_ALIAS
  146. keyPassword LESSPASS_RELEASE_KEY_PASSWORD
  147. }
  148. }
  149. }
  150. splits {
  151. abi {
  152. reset()
  153. enable enableSeparateBuildPerCPUArchitecture
  154. universalApk false // If true, also generate a universal APK
  155. include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
  156. }
  157. }
  158. buildTypes {
  159. debug {
  160. signingConfig signingConfigs.debug
  161. }
  162. release {
  163. minifyEnabled enableProguardInReleaseBuilds
  164. proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
  165. signingConfig signingConfigs.release
  166. }
  167. }
  168. packagingOptions {
  169. pickFirst "lib/armeabi-v7a/libc++_shared.so"
  170. pickFirst "lib/arm64-v8a/libc++_shared.so"
  171. pickFirst "lib/x86/libc++_shared.so"
  172. pickFirst "lib/x86_64/libc++_shared.so"
  173. }
  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. def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4]
  180. def abi = output.getFilter(OutputFile.ABI)
  181. if (abi != null) { // null for the universal-debug, universal-release variants
  182. output.versionCodeOverride =
  183. versionCodes.get(abi) * 10000000 + defaultConfig.versionCode
  184. }
  185. }
  186. }
  187. }
  188. dependencies {
  189. implementation fileTree(dir: "libs", include: ["*.jar"])
  190. //noinspection GradleDynamicVersion
  191. implementation "com.facebook.react:react-native:+" // From node_modules
  192. implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
  193. debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") {
  194. exclude group:'com.facebook.fbjni'
  195. }
  196. debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
  197. exclude group:'com.facebook.flipper'
  198. }
  199. debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") {
  200. exclude group:'com.facebook.flipper'
  201. }
  202. implementation "com.madgag.spongycastle:core:1.58.0.0"
  203. if (enableHermes) {
  204. def hermesPath = "../../node_modules/hermes-engine/android/";
  205. debugImplementation files(hermesPath + "hermes-debug.aar")
  206. releaseImplementation files(hermesPath + "hermes-release.aar")
  207. } else {
  208. implementation jscFlavor
  209. }
  210. testImplementation "junit:junit:4.12"
  211. }
  212. sourceSets {
  213. test {
  214. java {
  215. srcDirs = ["test"]
  216. }
  217. }
  218. }
  219. // Run this once to be able to run the application with BUCK
  220. // puts all compile dependencies into folder libs for BUCK to use
  221. task copyDownloadableDepsToLibs(type: Copy) {
  222. from configurations.compile
  223. into 'libs'
  224. }
  225. apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)