广告屏react-native项目
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 
 

199 строки
8.0 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
  17. * entryFile: "index.android.js",
  18. *
  19. * // whether to bundle JS and assets in debug mode
  20. * bundleInDebug: false,
  21. *
  22. * // whether to bundle JS and assets in release mode
  23. * bundleInRelease: true,
  24. *
  25. * // whether to bundle JS and assets in another build variant (if configured).
  26. * // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants
  27. * // The configuration property can be in the following formats
  28. * // 'bundleIn${productFlavor}${buildType}'
  29. * // 'bundleIn${buildType}'
  30. * // bundleInFreeDebug: true,
  31. * // bundleInPaidRelease: true,
  32. * // bundleInBeta: true,
  33. *
  34. * // whether to disable dev mode in custom build variants (by default only disabled in release)
  35. * // for example: to disable dev mode in the staging build type (if configured)
  36. * devDisabledInStaging: true,
  37. * // The configuration property can be in the following formats
  38. * // 'devDisabledIn${productFlavor}${buildType}'
  39. * // 'devDisabledIn${buildType}'
  40. *
  41. * // the root of your project, i.e. where "package.json" lives
  42. * root: "../../",
  43. *
  44. * // where to put the JS bundle asset in debug mode
  45. * jsBundleDirDebug: "$buildDir/intermediates/assets/debug",
  46. *
  47. * // where to put the JS bundle asset in release mode
  48. * jsBundleDirRelease: "$buildDir/intermediates/assets/release",
  49. *
  50. * // where to put drawable resources / React Native assets, e.g. the ones you use via
  51. * // require('./image.png')), in debug mode
  52. * resourcesDirDebug: "$buildDir/intermediates/res/merged/debug",
  53. *
  54. * // where to put drawable resources / React Native assets, e.g. the ones you use via
  55. * // require('./image.png')), in release mode
  56. * resourcesDirRelease: "$buildDir/intermediates/res/merged/release",
  57. *
  58. * // by default the gradle tasks are skipped if none of the JS files or assets change; this means
  59. * // that we don't look at files in android/ or ios/ to determine whether the tasks are up to
  60. * // date; if you have any other folders that you want to ignore for performance reasons (gradle
  61. * // indexes the entire tree), add them here. Alternatively, if you have JS files in android/
  62. * // for example, you might want to remove it from here.
  63. * inputExcludes: ["android/**", "ios/**"],
  64. *
  65. * // override which node gets called and with what additional arguments
  66. * nodeExecutableAndArgs: ["node"],
  67. *
  68. * // supply additional arguments to the packager
  69. * extraPackagerArgs: []
  70. * ]
  71. */
  72. project.ext.react = [
  73. entryFile: "index.js"
  74. ]
  75. apply from: "../../node_modules/react-native/react.gradle"
  76. apply from: "../../node_modules/react-native-code-push/android/codepush.gradle"
  77. /**
  78. * Set this to true to create two separate APKs instead of one:
  79. * - An APK that only works on ARM devices
  80. * - An APK that only works on x86 devices
  81. * The advantage is the size of the APK is reduced by about 4MB.
  82. * Upload all the APKs to the Play Store and people will download
  83. * the correct one based on the CPU architecture of their device.
  84. */
  85. def enableSeparateBuildPerCPUArchitecture = false
  86. /**
  87. * Run Proguard to shrink the Java bytecode in release builds.
  88. */
  89. def enableProguardInReleaseBuilds = false
  90. android {
  91. compileSdkVersion rootProject.ext.compileSdkVersion
  92. compileOptions {
  93. sourceCompatibility JavaVersion.VERSION_1_8
  94. targetCompatibility JavaVersion.VERSION_1_8
  95. }
  96. def getVersionCode = { ->
  97. return project.hasProperty('versionCode') ? Integer.parseInt(project.versionCode) : 1
  98. }
  99. def getVersionName = { ->
  100. return project.hasProperty('versionName') ? project.versionName : "1.0"
  101. }
  102. defaultConfig {
  103. applicationId "com.screenad"
  104. minSdkVersion rootProject.ext.minSdkVersion
  105. targetSdkVersion rootProject.ext.targetSdkVersion
  106. versionCode = getVersionCode()
  107. versionName getVersionName()
  108. }
  109. android.applicationVariants.all { variant ->
  110. variant.outputs.all {
  111. outputFileName = "screenad_" + variant.buildType.name + "_" + defaultConfig.versionCode + ".apk"
  112. }
  113. }
  114. splits {
  115. abi {
  116. reset()
  117. enable enableSeparateBuildPerCPUArchitecture
  118. universalApk false // If true, also generate a universal APK
  119. include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
  120. }
  121. }
  122. signingConfigs {
  123. release {
  124. if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
  125. storeFile file(MYAPP_RELEASE_STORE_FILE)
  126. storePassword MYAPP_RELEASE_STORE_PASSWORD
  127. keyAlias MYAPP_RELEASE_KEY_ALIAS
  128. keyPassword MYAPP_RELEASE_KEY_PASSWORD
  129. }
  130. }
  131. }
  132. buildTypes {
  133. debug {
  134. buildConfigField "String", "API_HOST", "\"https://mall.youlane.cn/\""
  135. buildConfigField "String", "CODEPUSH_HOST", "\"https://update.youlane.cn/\""
  136. buildConfigField "String", "CODEPUSH_KEY", "\"8snO1yoHlvhEtBjr02zTr3g1comw4ksvOXqog\""
  137. }
  138. release {
  139. buildConfigField "String", "API_HOST", "\"https://admintest.malls.iformall.com/\""
  140. buildConfigField "String", "CODEPUSH_HOST", "\"https://update.youlane.cn/\""
  141. buildConfigField "String", "CODEPUSH_KEY", "\"9rYZYySFD0ryN5wCD9YmjJkT55Kf4ksvOXqog\""
  142. minifyEnabled enableProguardInReleaseBuilds
  143. proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
  144. signingConfig signingConfigs.release
  145. }
  146. product.initWith(release)
  147. product {
  148. buildConfigField "String", "API_HOST", "\"https://admin.malls.iformall.com/\""
  149. buildConfigField "String", "CODEPUSH_HOST", "\"https://update.malls.iformall.com/\""
  150. buildConfigField "String", "CODEPUSH_KEY", "\"9rYZYySFD0ryN5wCD9YmjJkT55Kf4ksvOXqog\""
  151. matchingFallbacks = ['product', 'release']
  152. }
  153. }
  154. // applicationVariants are e.g. debug, release
  155. applicationVariants.all { variant ->
  156. variant.outputs.each { output ->
  157. // For each separate APK per architecture, set a unique version code as described here:
  158. // http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
  159. def versionCodes = ["armeabi-v7a":1, "x86":2, "arm64-v8a": 3, "x86_64": 4]
  160. def abi = output.getFilter(OutputFile.ABI)
  161. if (abi != null) { // null for the universal-debug, universal-release variants
  162. output.versionCodeOverride =
  163. versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
  164. }
  165. }
  166. }
  167. }
  168. dependencies {
  169. implementation project(':react-native-svg')
  170. implementation project(':react-native-camera')
  171. implementation project(':react-native-device-info')
  172. implementation project(':react-native-code-push')
  173. implementation fileTree(dir: "libs", include: ["*.jar"])
  174. implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
  175. implementation "com.facebook.react:react-native:+" // From node_modules
  176. }
  177. // Run this once to be able to run the application with BUCK
  178. // puts all compile dependencies into folder libs for BUCK to use
  179. task copyDownloadableDepsToLibs(type: Copy) {
  180. from configurations.compile
  181. into 'libs'
  182. }