| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279 |
- apply plugin: 'com.android.application'
- apply plugin: 'com.getkeepsafe.dexcount'
- apply plugin: 'me.tatarka.retrolambda'
- apply plugin: 'AndResGuard'
- //定义时间
- def releaseTime() {
- // return new Date().format("yyyyMMdd.HHmm.ss")
- return new Date().format("yyyyMMdd")
- }
- //设置发布的显示的版本号
- def getVersionName() {
- return rootProject.ext.android.versionName
- }
- //读取版本号
- def getVersionCode() {
- def versionFile = file('version.properties')
- if (versionFile.canRead()) {
- Properties versionProps = new Properties()
- versionProps.load(new FileInputStream(versionFile))
- def versionName = versionProps['versionName'].toInteger()
- def versionCode = versionProps['versionCode'].toInteger()
- def debugName = versionProps['debugName'].toInteger()
- def debugCode = versionProps['debugCode'].toInteger()
- def versionArray = new Integer[4]
- def runTasks = gradle.startParameter.taskNames //仅在assembleRelease任务是增加版本号
- println 'runTasks:' + runTasks
- if (':WeiChat:assembleBaiduDebug' in runTasks) {
- println 'runTasks:' + 'debug模式打包apk'
- versionProps['debugCode'] = (++debugCode).toString()
- versionProps['debugName'] = (++debugName).toString()
- versionProps.store(versionFile.newWriter(), null)
- }
- if (':WeiChat:assembleBaiduRelease' in runTasks) {
- println 'runTasks:' + '发布模式打包apk'
- versionProps['versionCode'] = (++versionCode).toString()
- versionProps['versionName'] = (++versionName).toString()
- versionProps.store(versionFile.newWriter(), null)
- }
- versionArray[0] = versionName
- versionArray[1] = versionCode
- versionArray[2] = debugName
- versionArray[3] = debugCode
- println versionArray[0].toString()
- return versionArray
- } else {
- throw new GradleException("Could not find version.properties!")
- }
- }
- android {
- def versionArray = getVersionCode()
- compileOptions {
- sourceCompatibility JavaVersion.VERSION_1_8
- targetCompatibility JavaVersion.VERSION_1_8
- }
- signingConfigs {
- config {
- storeFile file('C:/sigin/applicationsignname[20150409]')
- storePassword '13237658359'
- keyAlias 'jie-20150409'
- keyPassword '13237658359'
- }
- }
- compileSdkVersion rootProject.ext.android.compileSdkVersion
- buildToolsVersion rootProject.ext.android.buildToolsVersion
- defaultConfig {
- def versionNames = "v" + versionArray[0].toString().substring(0, 1) + "." + versionArray[0].toString().substring(1, 2) + "." + versionArray[0].toString().substring(2, 3)
- applicationId project.applicationId
- minSdkVersion rootProject.ext.android.minSdkVersion
- targetSdkVersion rootProject.ext.android.targetSdkVersion
- // versionCode rootProject.ext.android.versionCode
- // versionName rootProject.ext.android.versionName
- versionCode versionArray[1]
- versionName versionNames
- multiDexEnabled true
- signingConfig signingConfigs.config
- manifestPlaceholders = [UMENG_CHANNEL_VALUE: "umeng"]
- ndk {
- abiFilters "armeabi", "armeabi-v7a", "x86", "mips", "x86_64", "mips64"
- }
- }
- useLibrary 'org.apache.http.legacy'
- lintOptions {
- checkReleaseBuilds false
- abortOnError false
- }
- packagingOptions {
- exclude 'META-INF/LICENSE.txt'
- exclude 'META-INF/NOTICE.txt'
- }
- buildTypes {
- release {
- minifyEnabled false
- proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
- signingConfig signingConfigs.config
- }
- debug {
- signingConfig signingConfigs.config
- }
- }
- productFlavors {
- wandoujia {}
- _360 {}
- baidu {}
- xiaomi {}
- tencent {}
- taobao {}
- }
- productFlavors.all {
- flavor -> flavor.manifestPlaceholders = [UMENG_CHANNEL_VALUE: name]
- }
- /*applicationVariants.all { variant ->
- variant.outputs.each { output ->
- def outputFile = output.outputFile
- def fileName
- if (outputFile != null && outputFile.name.endsWith('.apk')) {
- if (variant.buildType.name.equals('release')) {
- //赋值app属性版本名
- //variant.mergedFlavor.versionName = getVersionName() + "_" + variant.productFlavors[0].name+"(Build"+currentVersionCode+")"
- //variant.mergedFlavor.versionName ="v"+versionArray[0].toString().substring(0,1)+"."+ versionArray[0].toString().substring(1,2)+"."+ versionArray[0].toString().substring(2,3)
- 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]+")"
- fileName = "WeiChat_${releaseInfo}_release.apk"
- } else if (variant.buildType.name.equals('debug')) {
- //赋值app属性版本名
- variant.mergedFlavor.versionName = getVersionName() + "_" + releaseTime() + "_" + variant.productFlavors[0].name+"(Build"+versionArray[3]+")"+"_debug"
- def debugInfo= getVersionName() + "_" + releaseTime() + "_" + variant.productFlavors[0].name+"(Build"+versionArray[3]+")"
- fileName = "WeiChat_${debugInfo}_debug.apk"
- }
- output.outputFile = new File(outputFile.parent, fileName)
- }
- }
- }*/
- }
- andResGuard {
- // mappingFile = file("./resource_mapping.txt")
- mappingFile = null
- use7zip = true
- useSign = true
- // 打开这个开关,会keep住所有资源的原始路径,只混淆资源的名字
- keepRoot = false
- whiteList = [
- // for your icon
- "R.drawable.uuu",
- // for fabric
- "R.string.com.crashlytics.*",
- // for google-services
- "R.string.google_app_id",
- "R.string.gcm_defaultSenderId",
- "R.string.default_web_client_id",
- "R.string.ga_trackingId",
- "R.string.firebase_database_url",
- "R.string.google_api_key",
- "R.string.google_crash_reporting_api_key",
- "R.dimen.rc_*",
- //for umeng
- "R.anim.umeng*",
- "R.string.umeng*",
- "R.string.UM*",
- "R.string.tb_*",
- "R.layout.umeng*",
- "R.layout.socialize_*",
- "R.layout.*messager*",
- "R.layout.tb_*",
- "R.color.umeng*",
- "R.color.tb_*",
- "R.style.*UM*",
- "R.style.rc_*",
- "R.style.umeng*",
- "R.drawable.umeng*",
- "R.drawable.tb_*",
- "R.drawable.sina*",
- "R.drawable.qq_*",
- "R.drawable.tb_*",
- "R.id.umeng*",
- "R.id.*messager*",
- "R.id.rc_*",
- "R.id.progress_bar_parent",
- "R.id.socialize_*",
- "R.id.webView",
- //for jpush
- "R.drawable.jpush_notification_icon"
- ]
- compressFilePattern = [
- "*.png",
- "*.jpg",
- "*.jpeg",
- "*.gif",
- ]
- sevenzip {
- artifact = 'com.tencent.mm:SevenZip:1.2.13'
- //path = "/usr/local/bin/7za"
- }
- /**
- * 可选: 如果不设置则会默认覆盖assemble输出的apk
- **/
- // finalApkBackupPath = "${project.rootDir}/final.apk"
- /**
- * 可选: 指定v1签名时生成jar文件的摘要算法
- * 默认值为“SHA-1”
- **/
- // digestalg = "SHA-256"
- }
- dependencies {
- compile fileTree(include: ['*.jar'], dir: 'libs')
- testCompile deps.junit
- compile deps.appcompatV7
- compile deps.design
- compile(deps.stetho) {
- force = true
- }
- compile deps.jodatime
- compile deps.systembartint
- compile deps.photoView
- compile deps.tagGroup
- compile deps.analytics
- compile deps.activityOnCrash
- compile deps.stickyListHeaders
- compile deps.stickyGridHeaders
- compile deps.materialDialogs
- compile deps.okhttp
- androidTestCompile deps.leakcanaryNp
- debugCompile deps.leakcanary
- releaseCompile deps.leakcanaryNp
- //project
- compile project(':common')
- compile project(':appmessages')
- compile project(':network')
- compile project(':imageload')
- compile project(':applogin')
- compile project(':apptasks')
- compile project(':appcontact')
- compile project(':appme')
- compile project(':appworks')
- compile project(':appbooking')
- // compile project(':android-pdf-viewer')
- compile project(':apputils')
- }
- buildscript {
- repositories {
- mavenCentral()
- }
- dependencies {
- classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.6.4'
- }
- }
- dexcount {
- format = "json"
- includeClasses = false
- includeFieldCount = true
- includeTotalMethodCount = false
- orderByMethodCount = false
- verbose = false
- maxTreeDepth = Integer.MAX_VALUE
- teamCityIntegration = false
- enableForInstantRun = false
- }
|