build.gradle 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. apply plugin: "com.android.application"
  2. apply plugin: "com.facebook.react"
  3. apply plugin: "com.google.gms.google-services"
  4. /**
  5. * This is the configuration block to customize your React Native Android app.
  6. * By default you don't need to apply any configuration, just uncomment the lines you need
  7. */
  8. react {
  9. /* Folders */
  10. // The root of your project, i.e. where "package.json" lives. Default is '..'
  11. // root = file("../")
  12. // The folder where the react-native NPM package is. Default is ../node_modules/react-native
  13. // reactNativeDir = file("../node_modules/react-native")
  14. // The folder where the react-native Codegen package is. Default is ../node_modules/@react-native/codegen
  15. // codegenDir = file("../node_modules/@react-native/codegen")
  16. // The cli.js file which is the React Native CLI entrypoint. Default is ../node_modules/react-native/cli.js
  17. // cliFile = file("../node_modules/react-native/cli.js")
  18. /* Variants */
  19. // The list of variants to that are debuggable. For those we're going to
  20. // skip the bundling of the JS bundle and the assets. By default is just 'debug'.
  21. // If you add flavors like lite, prod, etc. you'll have to list your debuggableVariants.
  22. // debuggableVariants = ["liteDebug", "prodDebug"]
  23. /* Bundling */
  24. // A list containing the node command and its flags. Default is just 'node'.
  25. // nodeExecutableAndArgs = ["node"]
  26. //
  27. // The command to run when bundling. By default is 'bundle'
  28. // bundleCommand = "ram-bundle"
  29. //
  30. // The path to the CLI configuration file. Default is empty.
  31. // bundleConfig = file(../rn-cli.config.js)
  32. //
  33. // The name of the generated asset file containing your JS bundle
  34. // bundleAssetName = "MyApplication.android.bundle"
  35. //
  36. // The entry file for bundle generation. Default is 'index.android.js' or 'index.js'
  37. // entryFile = file("../js/MyApplication.android.js")
  38. //
  39. // A list of extra flags to pass to the 'bundle' commands.
  40. // See https://github.com/react-native-community/cli/blob/main/docs/commands.md#bundle
  41. // extraPackagerArgs = []
  42. /* Hermes Commands */
  43. // The hermes compiler command to run. By default it is 'hermesc'
  44. // hermesCommand = "$rootDir/my-custom-hermesc/bin/hermesc"
  45. //
  46. // The list of flags to pass to the Hermes compiler. By default is "-O", "-output-source-map"
  47. // hermesFlags = ["-O", "-output-source-map"]
  48. }
  49. /**
  50. * Set this to true to Run Proguard on Release builds to minify the Java bytecode.
  51. */
  52. def enableProguardInReleaseBuilds = false
  53. /**
  54. * The preferred build flavor of JavaScriptCore (JSC)
  55. *
  56. * For example, to use the international variant, you can use:
  57. * `def jscFlavor = 'org.webkit:android-jsc-intl:+'`
  58. *
  59. * The international variant includes ICU i18n library and necessary data
  60. * allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that
  61. * give correct results when using with locales other than en-US. Note that
  62. * this variant is about 6MiB larger per architecture than default.
  63. */
  64. def jscFlavor = 'org.webkit:android-jsc:+'
  65. def getMyVersionCode() {
  66. def files = file('version.properties')
  67. Properties props = new Properties()
  68. props.load(new FileInputStream(files))
  69. def code = props['VERSION_CODE'].toInteger()
  70. //def task = gradle.startParameter.taskNames
  71. //if ('assembleRelease' in task) {
  72. code++
  73. //}
  74. props['VERSION_CODE'] = code.toString()
  75. props.store(files.newWriter(), null)
  76. return code
  77. }
  78. static def releaseTime() {
  79. return new Date().format("yyyyMMdd", TimeZone.getDefault());
  80. }
  81. android {
  82. ndkVersion rootProject.ext.ndkVersion
  83. compileSdkVersion rootProject.ext.compileSdkVersion
  84. buildToolsVersion rootProject.ext.buildToolsVersion
  85. namespace "com.strides.chargeco"
  86. defaultConfig {
  87. applicationId "com.strides.chargeco"
  88. minSdkVersion rootProject.ext.minSdkVersion
  89. targetSdkVersion rootProject.ext.targetSdkVersion
  90. versionCode getMyVersionCode()
  91. versionName rootProject.ext.versionName
  92. multiDexEnabled true
  93. missingDimensionStrategy 'react-native-camera', 'general'
  94. }
  95. signingConfigs {
  96. debug {
  97. storeFile file('vbea.keystore')
  98. storePassword 'dec2020'
  99. keyAlias 'vbea'
  100. keyPassword 'dec2020'
  101. }
  102. release {
  103. storeFile file('vbea.keystore')
  104. storePassword 'dec2020'
  105. keyAlias 'vbea'
  106. keyPassword 'dec2020'
  107. }
  108. }
  109. buildTypes {
  110. debug {
  111. signingConfig signingConfigs.debug
  112. //热更新应用分发Staging key
  113. resValue "string", "CodePushDeploymentKey", "zu0zkOWpBhXTGQ83pC15FW3puB--tuSG5TvIQ"
  114. }
  115. release {
  116. // Caution! In production, you need to generate your own keystore file.
  117. // see https://reactnative.dev/docs/signed-apk-android.
  118. signingConfig signingConfigs.release
  119. minifyEnabled enableProguardInReleaseBuilds
  120. proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
  121. ndk {
  122. abiFilters "armeabi", "armeabi-v7a", "arm64-v8a"
  123. }
  124. //热更新应用分发Production key
  125. resValue "string", "CodePushDeploymentKey", "rQGN1c2GXKx5EBT1scXipC9xwSQZMG62xiWOd"
  126. }
  127. }
  128. // applicationVariants are e.g. debug, release
  129. applicationVariants.all { variant ->
  130. variant.outputs.all { output ->
  131. if (variant.buildType.name=="release") {
  132. def fileName = "ChargEco-V${variant.versionName}-${variant.versionCode}"
  133. // 加入打包时间
  134. fileName = fileName + "-${releaseTime()}"
  135. // 加入版本类型
  136. fileName = fileName + "-${variant.buildType.name}.apk"
  137. //output.outputFile = new File(outputFile.parent, fileName)
  138. outputFileName = fileName
  139. }
  140. }
  141. }
  142. }
  143. dependencies {
  144. implementation fileTree(dir: "libs", include: ["*.jar"])
  145. // The version of react-native is set by the React Native Gradle Plugin
  146. implementation "com.facebook.react:react-android"
  147. //noinspection GradleDynamicVersion
  148. implementation "com.facebook.fresco:animated-gif:2.5.0" // 如果你需要支持GIF动图
  149. implementation "androidx.appcompat:appcompat:1.6.1"
  150. implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0"
  151. debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}")
  152. debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
  153. exclude group:'com.squareup.okhttp3', module:'okhttp'
  154. }
  155. debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") {
  156. exclude group:'com.facebook.flipper'
  157. }
  158. if (rootProject.ext.enableHermes) {
  159. implementation("com.facebook.react:hermes-android")
  160. } else {
  161. implementation jscFlavor
  162. }
  163. /*implementation(project(':react-native-maps')){
  164. exclude group: 'com.google.android.gms', module: 'play-services-base'
  165. exclude group: 'com.google.android.gms', module: 'play-services-maps'
  166. }
  167. implementation 'com.google.android.gms:play-services-base:17.2.1'*/
  168. /*implementation 'com.google.android.gms:play-services-maps:17.0.0'
  169. implementation 'com.google.maps.android:android-maps-utils:2.2.3'*/
  170. implementation platform('com.google.firebase:firebase-bom:32.0.0')
  171. implementation 'com.google.firebase:firebase-messaging'
  172. implementation 'com.google.firebase:firebase-analytics'
  173. }
  174. apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle")
  175. apply from: file("../../node_modules/react-native-vector-icons/fonts.gradle")
  176. applyNativeModulesAppBuildGradle(project)