build.gradle 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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.webrain.happywork"
  19. minSdkVersion rootProject.ext.minSdkVersion
  20. targetSdkVersion rootProject.ext.targetSdkVersion
  21. multiDexEnabled true
  22. versionCode 117
  23. versionName "1.1.7"
  24. testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
  25. flavorDimensions "versionCode"
  26. ndk {
  27. abiFilters "armeabi", "armeabi-v7a", "arm64-v8a", "x86", "arm64-v8a", "x86_64"
  28. }
  29. }
  30. productFlavors {
  31. hwpro {
  32. applicationId "com.webrain.happywork"
  33. buildConfigField('String', 'VERIFY_URL', "\"http://cw.dal-pay.com/captcha/captcha?phone=\"")
  34. buildConfigField('int', 'PLATFORM_ID', "1")
  35. buildConfigField('String', 'baseApiUrl', proApiUrl)
  36. }
  37. hwtest {
  38. applicationId "com.webrain.happywork.test"
  39. buildConfigField('String', 'VERIFY_URL', "\"http://yz.hap-job.com/captcha/captcha?phone=\"")
  40. buildConfigField('int', 'PLATFORM_ID', "5")
  41. buildConfigField('String', 'baseApiUrl', testApiUrl)
  42. }
  43. }
  44. signingConfigs {
  45. debug {
  46. keyAlias props['KEY_ALIAS']
  47. keyPassword props['KEY_PASSWORD']
  48. storeFile file(props['KEYSTORE_FILE'])
  49. storePassword props['KEYSTORE_PASSWORD']
  50. }
  51. release {
  52. keyAlias props['KEY_ALIAS']
  53. keyPassword props['KEY_PASSWORD']
  54. storeFile file(props['KEYSTORE_FILE'])
  55. storePassword props['KEYSTORE_PASSWORD']
  56. }
  57. }
  58. //自动生成指定名称的release发布版的 apk文件
  59. android.applicationVariants.all { variant ->
  60. variant.outputs.all { output ->
  61. outputFileName = "happyWork_${variant.productFlavors[0].name}_${buildType.getName()}_${defaultConfig.versionName}.apk"
  62. }
  63. }
  64. buildTypes {
  65. release {
  66. //混淆
  67. minifyEnabled true
  68. //Zipalign优化
  69. zipAlignEnabled true
  70. // 移除无用的resource文件
  71. shrinkResources true
  72. proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
  73. signingConfig signingConfigs.release
  74. }
  75. debug {
  76. signingConfig signingConfigs.release
  77. }
  78. }
  79. }
  80. dependencies {
  81. implementation fileTree(dir: 'libs', include: ['*.jar'])
  82. implementation project(':baselibrary')
  83. implementation 'com.jakewharton:butterknife:8.0.1'
  84. annotationProcessor 'com.jakewharton:butterknife-compiler:8.0.1'
  85. }