build.gradle
2.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.0"
defaultConfig {
applicationId "com.xiniunet.guard3"
minSdkVersion 15
targetSdkVersion 19
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
Properties props = new Properties()
props.load(new FileInputStream(file("../app/signing.properties")))
signingConfigs {//签名配置
releaseConfig {//发布版签名配置
storeFile file(props['KEYSTORE_FILE'])//密钥文件路径
keyAlias props['KEY_ALIAS']//key别名
storePassword props['KEYSTORE_PASSWORD']//密钥文件密码
keyPassword props['KEY_PASSWORD']//key密码
}
}
buildTypes {//build类型
release {//发布
debuggable false
minifyEnabled false //启用混淆
shrinkResources false //是否清理无用资源,依赖于minifyEnabled
zipAlignEnabled true //是否启用zipAlign压缩
signingConfig signingConfigs.releaseConfig//设置签名信息
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
//修改生成的apk名字,格式为 app名_版本号_打包时间_渠道名_release.apk
applicationVariants.all { variant ->
variant.outputs.each { output ->
def oldFile = output.outputFile
def releaseApkName = "guard" + "_v${defaultConfig.versionName}_${releaseTime()}_" + variant.buildType.name + '.apk'
output.outputFile = new File(oldFile.parent, releaseApkName)
}
}
}
/**
* 发布时间
* @return
*/
def releaseTime() {
return new Date().format("yyyy-MM-dd", TimeZone.getTimeZone("UTC"))
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.0.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
compile 'com.youth.banner:banner:1.4.10'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile files('libs/xntalk-android-sdk-1.4.0-SNAPSHOT.jar')
compile files('libs/xntalk-android-sdk-1.4.0-SNAPSHOT-sources.jar')
compile 'com.yanzhenjie.nohttp:okhttp:1.1.8'
compile 'com.alibaba:fastjson:1.1.46.android'
compile 'com.elvishew:xlog:1.4.0'
}