Advertisement
sytolk

Gradle.build

Jun 25th, 2018
1,372
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.53 KB | None | 0 0
  1. apply plugin: "com.android.application"
  2. apply plugin: 'project-report'
  3.  
  4. import com.android.build.OutputFile
  5.  
  6. /**
  7. * The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets
  8. * and bundleReleaseJsAndAssets).
  9. * These basically call `react-native bundle` with the correct arguments during the Android build
  10. * cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the
  11. * bundle directly from the development server. Below you can see all the possible configurations
  12. * and their defaults. If you decide to add a configuration block, make sure to add it before the
  13. * `apply from: "../../node_modules/react-native/react.gradle"` line.
  14. *
  15. * project.ext.react = [
  16. * // the name of the generated asset file containing your JS bundle
  17. * bundleAssetName: "index.android.bundle",
  18. *
  19. * // the entry file for bundle generation
  20. * entryFile: "index.android.js",
  21. *
  22. * // whether to bundle JS and assets in debug mode
  23. * bundleInDebug: false,
  24. *
  25. * // whether to bundle JS and assets in release mode
  26. * bundleInRelease: true,
  27. *
  28. * // whether to bundle JS and assets in another build variant (if configured).
  29. * // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants
  30. * // The configuration property can be in the following formats
  31. * // 'bundleIn${productFlavor}${buildType}'
  32. * // 'bundleIn${buildType}'
  33. * // bundleInFreeDebug: true,
  34. * // bundleInPaidRelease: true,
  35. * // bundleInBeta: true,
  36. *
  37. * // whether to disable dev mode in custom build variants (by default only disabled in release)
  38. * // for example: to disable dev mode in the staging build type (if configured)
  39. * devDisabledInStaging: true,
  40. * // The configuration property can be in the following formats
  41. * // 'devDisabledIn${productFlavor}${buildType}'
  42. * // 'devDisabledIn${buildType}'
  43. *
  44. * // the root of your project, i.e. where "package.json" lives
  45. * root: "../../",
  46. *
  47. * // where to put the JS bundle asset in debug mode
  48. * jsBundleDirDebug: "$buildDir/intermediates/assets/debug",
  49. *
  50. * // where to put the JS bundle asset in release mode
  51. * jsBundleDirRelease: "$buildDir/intermediates/assets/release",
  52. *
  53. * // where to put drawable resources / React Native assets, e.g. the ones you use via
  54. * // require('./image.png')), in debug mode
  55. * resourcesDirDebug: "$buildDir/intermediates/res/merged/debug",
  56. *
  57. * // where to put drawable resources / React Native assets, e.g. the ones you use via
  58. * // require('./image.png')), in release mode
  59. * resourcesDirRelease: "$buildDir/intermediates/res/merged/release",
  60. *
  61. * // by default the gradle tasks are skipped if none of the JS files or assets change; this means
  62. * // that we don't look at files in android/ or ios/ to determine whether the tasks are up to
  63. * // date; if you have any other folders that you want to ignore for performance reasons (gradle
  64. * // indexes the entire tree), add them here. Alternatively, if you have JS files in android/
  65. * // for example, you might want to remove it from here.
  66. * inputExcludes: ["android/**", "ios/**"],
  67. *
  68. * // override which node gets called and with what additional arguments
  69. * nodeExecutableAndArgs: ["node"],
  70. *
  71. * // supply additional arguments to the packager
  72. * extraPackagerArgs: []
  73. * ]
  74. */
  75.  
  76. ext.node_binary = System.getenv("NODE_BINARY")
  77. project.ext.react = [
  78. entryFile: "index.js",
  79. bundleInSnapshot: true,
  80. devDisabledInSnapshot: true,
  81. nodeExecutableAndArgs: ext.node_binary ? [ext.node_binary] : null
  82. ]
  83.  
  84. apply from: "../../node_modules/react-native/react.gradle"
  85.  
  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. /**
  97. * Run Proguard to shrink the Java bytecode in release builds.
  98. */
  99. def enableProguardInReleaseBuilds = false
  100.  
  101. android {
  102. defaultConfig {
  103. applicationId "com.testapp"
  104. minSdkVersion 19
  105. targetSdkVersion 22
  106. missingDimensionStrategy "RNN.reactNativeVersion", "reactNative55"
  107. ndk {
  108. abiFilters "armeabi-v7a", "x86"
  109. }
  110. multiDexEnabled true
  111. vectorDrawables.useSupportLibrary = true
  112. }
  113. packagingOptions {
  114. exclude 'META-INF/LICENSE'
  115. exclude 'META-INF/DEPENDENCIES.txt'
  116. exclude 'META-INF/LICENSE.txt'
  117. exclude 'META-INF/NOTICE.txt'
  118. exclude 'META-INF/NOTICE'
  119. exclude 'META-INF/DEPENDENCIES'
  120. exclude 'META-INF/notice.txt'
  121. exclude 'META-INF/license.txt'
  122. exclude 'META-INF/dependencies.txt'
  123. exclude 'META-INF/LGPL2.1'
  124. }
  125. compileOptions {
  126. sourceCompatibility JavaVersion.VERSION_1_8
  127. targetCompatibility JavaVersion.VERSION_1_8
  128. }
  129. splits {
  130. abi {
  131. reset()
  132. enable enableSeparateBuildPerCPUArchitecture
  133. universalApk false // If true, also generate a universal APK
  134. include "armeabi-v7a", "x86"
  135. }
  136. }
  137. buildTypes {
  138. debug {
  139. minifyEnabled false
  140. applicationIdSuffix ".debug"
  141. }
  142. release {
  143. minifyEnabled enableProguardInReleaseBuilds
  144. }
  145. }
  146. // applicationVariants are e.g. debug, release
  147. applicationVariants.all { variant ->
  148. variant.outputs.each { output ->
  149. // For each separate APK per architecture, set a unique version code as described here:
  150. // http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
  151. def versionCodes = ["armeabi-v7a":1, "x86":2]
  152. def abi = output.getFilter(OutputFile.ABI)
  153. if (abi != null) { // null for the universal-debug, universal-release variants
  154. output.versionCodeOverride =
  155. versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
  156. }
  157. }
  158. }
  159.  
  160. lintOptions {
  161. disable 'InvalidPackage'
  162. abortOnError false
  163. }
  164. }
  165.  
  166. configurations.all {
  167. // OkHttp 3.5.0+ includes the websockets API, so we need this to prevent a conflict
  168. // https://github.com/square/okhttp/issues/3040
  169. // exclude module: 'okhttp-ws'
  170.  
  171. resolutionStrategy {
  172. force "com.android.support:support-annotations:$support_version"
  173. force "com.android.support:support-v4:$support_version"
  174. force "com.android.support:support-v13:$support_version"
  175. force "com.android.support:appcompat-v7:$support_version"
  176. force "com.android.support:recyclerview-v7:$support_version"
  177. force "com.android.support:design:$support_version"
  178. force "com.google.android.gms:play-services-base:$gms_version"
  179. force "com.google.android.gms:play-services-basement:$gms_version"
  180. force "com.google.android.gms:play-services-maps:$gms_version"
  181. force "com.google.android.gms:play-services-location:$gms_version"
  182. force "com.google.android.gms:play-services-gcm:$gms_version"
  183. force "com.google.android.gms:play-services-iid:$gms_version"
  184. force "com.google.android.gms:play-services-fitness:$gms_version"
  185. force "com.google.android.gms:play-services-analytics:$gms_version"
  186. force "com.google.android.gms:play-services-analytics-impl:$gms_version"
  187. force "com.google.android.gms:play-services-tagmanager-v4-impl:$gms_version"
  188. force "com.google.android.gms:play-services-tasks:$gms_version"
  189. force "com.google.firebase:firebase-core:$gms_version"
  190. force "com.google.firebase:firebase-config:$gms_version"
  191. force "com.google.firebase:firebase-auth:$gms_version"
  192. force "com.google.firebase:firebase-analytics:$gms_version"
  193. force "com.google.firebase:firebase-analytics-impl:$gms_version"
  194. force "com.google.firebase:firebase-database:$gms_version"
  195. force "com.google.firebase:firebase-messaging:$gms_version"
  196. force "com.google.firebase:firebase-storage:$gms_version"
  197. force "com.google.firebase:firebase-crash:$gms_version"
  198. force "com.google.firebase:firebase-iid:$gms_version"
  199. force "com.google.firebase:firebase-common:$gms_version"
  200. // force 'com.squareup.okhttp3:okhttp:3.4.1'
  201. // force 'com.squareup.okhttp3:okhttp:3.6.0'
  202. force 'com.squareup.okhttp3:okhttp:3.10.0'
  203. }
  204. }
  205.  
  206.  
  207. dependencies {
  208. implementation project(':react-native-device-info')
  209. implementation project(':react-native-google-places')
  210. implementation project(':react-native-config')
  211. implementation project(':react-native-svg')
  212. implementation project(':react-native-settings')
  213. implementation project(':react-native-maps')
  214. implementation project(':react-native-mail')
  215. implementation project(':react-native-i18n')
  216. implementation project(':react-native-google-api-availability-bridge')
  217. implementation project(':react-native-google-analytics-bridge')
  218. implementation project(':react-native-fs')
  219. implementation fileTree(dir: "libs", include: ["*.jar"])
  220. implementation "com.android.support:appcompat-v7:$support_version"
  221. implementation "com.facebook.react:react-native:+" // From node_modules
  222. implementation project(':react-native-navigation')
  223. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement