build.gradle 7.4 KB

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