build.gradle 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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 350
  24. versionName "3.5.0"
  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. buildConfigField('String', 'VERIFY_URL', "\"https://tw.hap-job.com/captcha/captcha?phone=\"")
  37. manifestPlaceholders = [
  38. AMAP_KEY : "0e0cda5ece292d81a67ab1277973164d",
  39. WX_APPID_VALUE: "wxeb8c2418a8ace030",
  40. ]
  41. }
  42. hbtest {
  43. applicationId "com.tongyu.luck.happywork.test"
  44. buildConfigField('String', 'baseApiUrl', testApiUrl)
  45. buildConfigField('String', 'BUGLY_ID', "\"ea1dc909cd\"")
  46. buildConfigField('String', 'VERIFY_URL', "\"https://dk.hap-job.com/captcha/captcha?phone=\"")
  47. manifestPlaceholders = [
  48. AMAP_KEY : "af3f5c403ce607e9603e5087b1b2c961",
  49. WX_APPID_VALUE: "wx9c053f7126db0b28",
  50. ]
  51. }
  52. }
  53. signingConfigs {
  54. debug {
  55. keyAlias props['KEY_ALIAS']
  56. keyPassword props['KEY_PASSWORD']
  57. storeFile file(props['KEYSTORE_FILE'])
  58. storePassword props['KEYSTORE_PASSWORD']
  59. }
  60. release {
  61. keyAlias props['KEY_ALIAS']
  62. keyPassword props['KEY_PASSWORD']
  63. storeFile file(props['KEYSTORE_FILE'])
  64. storePassword props['KEYSTORE_PASSWORD']
  65. }
  66. }
  67. //自动生成指定名称的release发布版的 apk文件
  68. android.applicationVariants.all { variant ->
  69. variant.outputs.all { output ->
  70. outputFileName = "happyJob_${variant.productFlavors[0].name}_${buildType.getName()}_${defaultConfig.versionName}.apk"
  71. }
  72. }
  73. buildTypes {
  74. release {
  75. //混淆
  76. minifyEnabled true
  77. //Zipalign优化
  78. zipAlignEnabled true
  79. // 移除无用的resource文件
  80. shrinkResources true
  81. proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
  82. signingConfig signingConfigs.release
  83. }
  84. debug {
  85. signingConfig signingConfigs.release
  86. }
  87. }
  88. sourceSets {
  89. main {
  90. jniLibs.srcDirs = ['libs']
  91. }
  92. }
  93. // java 版本支持1.8
  94. compileOptions {
  95. sourceCompatibility JavaVersion.VERSION_1_8
  96. targetCompatibility JavaVersion.VERSION_1_8
  97. }
  98. }
  99. dependencies {
  100. implementation fileTree(include: ['*.jar'], dir: 'libs')
  101. implementation project(':baselibrary')
  102. implementation 'com.jakewharton:butterknife:8.0.1'
  103. annotationProcessor 'com.jakewharton:butterknife-compiler:8.0.1'
  104. }