build.gradle 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. ext.mainApp = true //设置为true,表示此module为主app module,一直以application方式编译
  2. apply from: rootProject.file('cc-settings.gradle')
  3. apply from: rootProject.file('common-build.gradle')
  4. android {
  5. compileSdkVersion rootProject.compile_sdk_version
  6. defaultConfig {
  7. applicationId rootProject.application_id
  8. minSdkVersion rootProject.min_sdk_version
  9. targetSdkVersion rootProject.target_sdk_version
  10. versionCode rootProject.application_version_code
  11. versionName rootProject.application_version_name
  12. ndk {
  13. //选择要添加的对应 cpu 类型的 .so 库。
  14. abiFilters 'armeabi-v7a'
  15. // 还可以添加 'x86', 'x86_64', 'mips', 'mips64'
  16. }
  17. }
  18. signingConfigs {
  19. release {
  20. keyAlias "heifengwuliu"
  21. keyPassword "HiFengwuliu@###121"
  22. storeFile file("../heifengwuliu.jks")
  23. storePassword "HiFengwuliu@###121"
  24. v2SigningEnabled true
  25. }
  26. }
  27. buildTypes {
  28. debug {
  29. signingConfig signingConfigs.release
  30. versionNameSuffix "-" + name
  31. }
  32. release {
  33. debuggable false
  34. minifyEnabled true
  35. zipAlignEnabled true
  36. shrinkResources true
  37. proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
  38. signingConfig signingConfigs.release
  39. }
  40. }
  41. //指定release APK名称
  42. applicationVariants.all { variant ->
  43. variant.outputs.all {
  44. // 输出apk名称为 1.0_vivo.apk
  45. def fileName = "${variant.productFlavors[0].name}_${defaultConfig.versionName}.apk"
  46. outputFileName = fileName
  47. }
  48. }
  49. flavorDimensions "version"
  50. //指定渠道
  51. productFlavors {
  52. dev {}
  53. vivo {}
  54. oppo {}
  55. huawei {}
  56. xiaomi {}
  57. coolapk {}
  58. yingyongbao {}
  59. }
  60. // 批量渠道包值替换
  61. //通过脚本获取所有渠道
  62. //在Terminal控制台输入gradlew assembleRelease开始打包
  63. //包生成在build-->outputs-->apk文件夹
  64. productFlavors.all {
  65. // 遍历替换所有渠道
  66. flavor -> flavor.manifestPlaceholders = [UMENG_CHANNEL: name]
  67. }
  68. //
  69. //Terminal窗口输入
  70. //打包wandoujia渠道的release版本,执行如下命令
  71. // gradlew assembleWandoujiaRelease
  72. //打包wandoujia渠道的debug版本,执行如下命令
  73. // gradlew assembleWandoujiaDebug
  74. // 只打wandoujia渠道版会生成wandoujia渠道的Release和Debug版本
  75. // gradlew assembleWandoujia
  76. //打全部Release版本
  77. // gradlew assembleRelease
  78. compileOptions {
  79. targetCompatibility 1.8
  80. sourceCompatibility 1.8
  81. }
  82. kotlinOptions {
  83. jvmTarget = '1.8'
  84. }
  85. android.buildFeatures {
  86. dataBinding = true
  87. viewBinding = false
  88. }
  89. }
  90. dependencies {
  91. implementation project(':base')
  92. addComponent 'update'
  93. addComponent 'umeng'
  94. // 底部菜单
  95. implementation('com.flyco.tablayout:FlycoTabLayout_Lib:2.1.2@aar') {
  96. exclude group: 'com.android.support', module: 'support-v4'
  97. }
  98. }