build.gradle 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. apply plugin: 'com.android.application'
  2. apply plugin: 'com.getkeepsafe.dexcount'
  3. apply plugin: 'me.tatarka.retrolambda'
  4. apply plugin: 'AndResGuard'
  5. //定义时间
  6. def releaseTime() {
  7. // return new Date().format("yyyyMMdd.HHmm.ss")
  8. return new Date().format("yyyyMMdd")
  9. }
  10. //设置发布的显示的版本号
  11. def getVersionName() {
  12. return rootProject.ext.android.versionName
  13. }
  14. //读取版本号
  15. def getVersionCode() {
  16. def versionFile = file('version.properties')
  17. if (versionFile.canRead()) {
  18. Properties versionProps = new Properties()
  19. versionProps.load(new FileInputStream(versionFile))
  20. def versionName = versionProps['versionName'].toInteger()
  21. def versionCode = versionProps['versionCode'].toInteger()
  22. def debugName = versionProps['debugName'].toInteger()
  23. def debugCode = versionProps['debugCode'].toInteger()
  24. def versionArray = new Integer[4]
  25. def runTasks = gradle.startParameter.taskNames //仅在assembleRelease任务是增加版本号
  26. println 'runTasks:' + runTasks
  27. if (':WeiChat:assembleBaiduDebug' in runTasks) {
  28. println 'runTasks:' + 'debug模式打包apk'
  29. versionProps['debugCode'] = (++debugCode).toString()
  30. versionProps['debugName'] = (++debugName).toString()
  31. versionProps.store(versionFile.newWriter(), null)
  32. }
  33. if (':WeiChat:assembleBaiduRelease' in runTasks) {
  34. println 'runTasks:' + '发布模式打包apk'
  35. versionProps['versionCode'] = (++versionCode).toString()
  36. versionProps['versionName'] = (++versionName).toString()
  37. versionProps.store(versionFile.newWriter(), null)
  38. }
  39. versionArray[0] = versionName
  40. versionArray[1] = versionCode
  41. versionArray[2] = debugName
  42. versionArray[3] = debugCode
  43. println versionArray[0].toString()
  44. return versionArray
  45. } else {
  46. throw new GradleException("Could not find version.properties!")
  47. }
  48. }
  49. android {
  50. def versionArray = getVersionCode()
  51. compileOptions {
  52. sourceCompatibility JavaVersion.VERSION_1_8
  53. targetCompatibility JavaVersion.VERSION_1_8
  54. }
  55. signingConfigs {
  56. config {
  57. storeFile file('C:/sigin/applicationsignname[20150409]')
  58. storePassword '13237658359'
  59. keyAlias 'jie-20150409'
  60. keyPassword '13237658359'
  61. }
  62. }
  63. compileSdkVersion rootProject.ext.android.compileSdkVersion
  64. buildToolsVersion rootProject.ext.android.buildToolsVersion
  65. defaultConfig {
  66. def versionNames = "v" + versionArray[0].toString().substring(0, 1) + "." + versionArray[0].toString().substring(1, 2) + "." + versionArray[0].toString().substring(2, 3)
  67. applicationId project.applicationId
  68. minSdkVersion rootProject.ext.android.minSdkVersion
  69. targetSdkVersion rootProject.ext.android.targetSdkVersion
  70. // versionCode rootProject.ext.android.versionCode
  71. // versionName rootProject.ext.android.versionName
  72. versionCode versionArray[1]
  73. versionName versionNames
  74. multiDexEnabled true
  75. signingConfig signingConfigs.config
  76. manifestPlaceholders = [UMENG_CHANNEL_VALUE: "umeng"]
  77. ndk {
  78. abiFilters "armeabi", "armeabi-v7a", "x86", "mips", "x86_64", "mips64"
  79. }
  80. }
  81. useLibrary 'org.apache.http.legacy'
  82. lintOptions {
  83. checkReleaseBuilds false
  84. abortOnError false
  85. }
  86. packagingOptions {
  87. exclude 'META-INF/LICENSE.txt'
  88. exclude 'META-INF/NOTICE.txt'
  89. }
  90. buildTypes {
  91. release {
  92. minifyEnabled false
  93. proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
  94. signingConfig signingConfigs.config
  95. }
  96. debug {
  97. signingConfig signingConfigs.config
  98. }
  99. }
  100. productFlavors {
  101. wandoujia {}
  102. _360 {}
  103. baidu {}
  104. xiaomi {}
  105. tencent {}
  106. taobao {}
  107. }
  108. productFlavors.all {
  109. flavor -> flavor.manifestPlaceholders = [UMENG_CHANNEL_VALUE: name]
  110. }
  111. /*applicationVariants.all { variant ->
  112. variant.outputs.each { output ->
  113. def outputFile = output.outputFile
  114. def fileName
  115. if (outputFile != null && outputFile.name.endsWith('.apk')) {
  116. if (variant.buildType.name.equals('release')) {
  117. //赋值app属性版本名
  118. //variant.mergedFlavor.versionName = getVersionName() + "_" + variant.productFlavors[0].name+"(Build"+currentVersionCode+")"
  119. //variant.mergedFlavor.versionName ="v"+versionArray[0].toString().substring(0,1)+"."+ versionArray[0].toString().substring(1,2)+"."+ versionArray[0].toString().substring(2,3)
  120. def releaseInfo= "v"+versionArray[0].toString().substring(0,1)+"."+ versionArray[0].toString().substring(1,2)+"."+ versionArray[0].toString().substring(2,3)+ "_" + variant.productFlavors[0].name+"(Build"+versionArray[1]+")"
  121. fileName = "WeiChat_${releaseInfo}_release.apk"
  122. } else if (variant.buildType.name.equals('debug')) {
  123. //赋值app属性版本名
  124. variant.mergedFlavor.versionName = getVersionName() + "_" + releaseTime() + "_" + variant.productFlavors[0].name+"(Build"+versionArray[3]+")"+"_debug"
  125. def debugInfo= getVersionName() + "_" + releaseTime() + "_" + variant.productFlavors[0].name+"(Build"+versionArray[3]+")"
  126. fileName = "WeiChat_${debugInfo}_debug.apk"
  127. }
  128. output.outputFile = new File(outputFile.parent, fileName)
  129. }
  130. }
  131. }*/
  132. }
  133. andResGuard {
  134. // mappingFile = file("./resource_mapping.txt")
  135. mappingFile = null
  136. use7zip = true
  137. useSign = true
  138. // 打开这个开关,会keep住所有资源的原始路径,只混淆资源的名字
  139. keepRoot = false
  140. whiteList = [
  141. // for your icon
  142. "R.drawable.uuu",
  143. // for fabric
  144. "R.string.com.crashlytics.*",
  145. // for google-services
  146. "R.string.google_app_id",
  147. "R.string.gcm_defaultSenderId",
  148. "R.string.default_web_client_id",
  149. "R.string.ga_trackingId",
  150. "R.string.firebase_database_url",
  151. "R.string.google_api_key",
  152. "R.string.google_crash_reporting_api_key",
  153. "R.dimen.rc_*",
  154. //for umeng
  155. "R.anim.umeng*",
  156. "R.string.umeng*",
  157. "R.string.UM*",
  158. "R.string.tb_*",
  159. "R.layout.umeng*",
  160. "R.layout.socialize_*",
  161. "R.layout.*messager*",
  162. "R.layout.tb_*",
  163. "R.color.umeng*",
  164. "R.color.tb_*",
  165. "R.style.*UM*",
  166. "R.style.rc_*",
  167. "R.style.umeng*",
  168. "R.drawable.umeng*",
  169. "R.drawable.tb_*",
  170. "R.drawable.sina*",
  171. "R.drawable.qq_*",
  172. "R.drawable.tb_*",
  173. "R.id.umeng*",
  174. "R.id.*messager*",
  175. "R.id.rc_*",
  176. "R.id.progress_bar_parent",
  177. "R.id.socialize_*",
  178. "R.id.webView",
  179. //for jpush
  180. "R.drawable.jpush_notification_icon"
  181. ]
  182. compressFilePattern = [
  183. "*.png",
  184. "*.jpg",
  185. "*.jpeg",
  186. "*.gif",
  187. ]
  188. sevenzip {
  189. artifact = 'com.tencent.mm:SevenZip:1.2.13'
  190. //path = "/usr/local/bin/7za"
  191. }
  192. /**
  193. * 可选: 如果不设置则会默认覆盖assemble输出的apk
  194. **/
  195. // finalApkBackupPath = "${project.rootDir}/final.apk"
  196. /**
  197. * 可选: 指定v1签名时生成jar文件的摘要算法
  198. * 默认值为“SHA-1”
  199. **/
  200. // digestalg = "SHA-256"
  201. }
  202. dependencies {
  203. compile fileTree(include: ['*.jar'], dir: 'libs')
  204. testCompile deps.junit
  205. compile deps.appcompatV7
  206. compile deps.design
  207. compile(deps.stetho) {
  208. force = true
  209. }
  210. compile deps.jodatime
  211. compile deps.systembartint
  212. compile deps.photoView
  213. compile deps.tagGroup
  214. compile deps.analytics
  215. compile deps.activityOnCrash
  216. compile deps.stickyListHeaders
  217. compile deps.stickyGridHeaders
  218. compile deps.materialDialogs
  219. compile deps.okhttp
  220. androidTestCompile deps.leakcanaryNp
  221. debugCompile deps.leakcanary
  222. releaseCompile deps.leakcanaryNp
  223. //project
  224. compile project(':common')
  225. compile project(':appmessages')
  226. compile project(':network')
  227. compile project(':imageload')
  228. compile project(':applogin')
  229. compile project(':apptasks')
  230. compile project(':appcontact')
  231. compile project(':appme')
  232. compile project(':appworks')
  233. compile project(':appbooking')
  234. // compile project(':android-pdf-viewer')
  235. compile project(':apputils')
  236. }
  237. buildscript {
  238. repositories {
  239. mavenCentral()
  240. }
  241. dependencies {
  242. classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.6.4'
  243. }
  244. }
  245. dexcount {
  246. format = "json"
  247. includeClasses = false
  248. includeFieldCount = true
  249. includeTotalMethodCount = false
  250. orderByMethodCount = false
  251. verbose = false
  252. maxTreeDepth = Integer.MAX_VALUE
  253. teamCityIntegration = false
  254. enableForInstantRun = false
  255. }