build.gradle 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. apply plugin: 'com.android.application'
  2. Properties props = new Properties()
  3. props.load(new FileInputStream(file("signing.properties")))
  4. Properties serverProps = new Properties()
  5. def propFile = file('server_url.properties')
  6. def testApiUrl, proApiUrl
  7. if (propFile.canRead()) {
  8. serverProps.load(new FileInputStream(propFile))
  9. if (serverProps != null) {
  10. testApiUrl = serverProps['testApiUrl']
  11. proApiUrl = serverProps['proApiUrl']
  12. }
  13. }
  14. android {
  15. compileSdkVersion rootProject.ext.compileSdkVersion
  16. buildToolsVersion rootProject.ext.buildToolsVersion
  17. defaultConfig {
  18. applicationId "com.tongyu.luck.happywork"
  19. minSdkVersion rootProject.ext.minSdkVersion
  20. targetSdkVersion rootProject.ext.targetSdkVersion
  21. multiDexEnabled true
  22. multiDexKeepProguard file("multidexKeep.pro")//腾讯bugly的类放到主Dex
  23. versionCode 339
  24. versionName "3.3.9"
  25. testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
  26. flavorDimensions "versionCode"
  27. ndk {
  28. abiFilters "armeabi", "armeabi-v7a", "arm64-v8a", "x86", "arm64-v8a", "x86_64"
  29. }
  30. }
  31. productFlavors {
  32. hbpro {
  33. applicationId "com.tongyu.luck.happywork"
  34. buildConfigField('String', 'baseApiUrl', proApiUrl)
  35. buildConfigField('String', 'BUGLY_ID', "\"f39e8bfcb6\"")
  36. manifestPlaceholders = [
  37. AMAP_KEY : "0e0cda5ece292d81a67ab1277973164d",
  38. WX_APPID_VALUE: "wxeb8c2418a8ace030",
  39. ]
  40. }
  41. hbtest {
  42. applicationId "com.tongyu.luck.happywork.test"
  43. buildConfigField('String', 'baseApiUrl', testApiUrl)
  44. buildConfigField('String', 'BUGLY_ID', "\"ea1dc909cd\"")
  45. manifestPlaceholders = [
  46. AMAP_KEY : "af3f5c403ce607e9603e5087b1b2c961",
  47. WX_APPID_VALUE: "wx9c053f7126db0b28",
  48. ]
  49. }
  50. }
  51. signingConfigs {
  52. debug {
  53. keyAlias props['KEY_ALIAS']
  54. keyPassword props['KEY_PASSWORD']
  55. storeFile file(props['KEYSTORE_FILE'])
  56. storePassword props['KEYSTORE_PASSWORD']
  57. }
  58. release {
  59. keyAlias props['KEY_ALIAS']
  60. keyPassword props['KEY_PASSWORD']
  61. storeFile file(props['KEYSTORE_FILE'])
  62. storePassword props['KEYSTORE_PASSWORD']
  63. }
  64. }
  65. //自动生成指定名称的release发布版的 apk文件
  66. android.applicationVariants.all { variant ->
  67. variant.outputs.all { output ->
  68. outputFileName = "happyJob_${variant.productFlavors[0].name}_${buildType.getName()}_${defaultConfig.versionName}.apk"
  69. }
  70. }
  71. buildTypes {
  72. release {
  73. //混淆
  74. minifyEnabled true
  75. //Zipalign优化
  76. zipAlignEnabled true
  77. // 移除无用的resource文件
  78. shrinkResources true
  79. proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
  80. signingConfig signingConfigs.release
  81. }
  82. debug {
  83. signingConfig signingConfigs.release
  84. }
  85. }
  86. }
  87. dependencies {
  88. implementation fileTree(include: ['*.jar'], dir: 'libs')
  89. implementation project(':baselibrary')
  90. implementation 'com.jakewharton:butterknife:8.0.1'
  91. annotationProcessor 'com.jakewharton:butterknife-compiler:8.0.1'
  92. }