build.gradle 7.5 KB

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