https://blog.csdn.net/and_you_with_me/article/details/78799226
## 举例
~~~
apply plugin: 'com.android.application'
// 当前beta版本号
ext.build_number = "beta1";
// 显示的时间格式,形如20171110
def releaseTime() {
return new Date().format("yyyyMMdd", TimeZone.getDefault());
}
android {
useLibrary 'org.apache.http.legacy'
compileSdkVersion 25
buildToolsVersion "27.0.3"
defaultConfig {
applicationId "com.jinnong"
minSdkVersion 14
targetSdkVersion 25
versionCode 6
versionName "1.0.6"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
applicationVariants.all { variant ->
variant.outputs.each { output ->
def outputFile = output.outputFile
if (outputFile != null && outputFile.name.endsWith('.apk')) {
// 显示app名称+当前版本号
def fileName = "TouchH-V${variant.versionName}"
// 如果有渠道,显示渠道名""
if (variant.flavorName!=""){
fileName = fileName + "-${variant.flavorName}"
}
// 加入打包时间
fileName = fileName + "-${releaseTime()}"
// 如果是debug版本,加入beta版本号
if ('debug'.equals(variant.buildType.name)) {
fileName = fileName + "-${build_number}.apk"
} else {
// 如果是release版本,直接显示
fileName = fileName + "-release.apk"
}
output.outputFile = new File(outputFile.parent, fileName)
}
}
}
signingConfigs {
release {
keyAlias 'jnkey'
keyPassword '123456'
storeFile file('C:/Users/Administrator/Desktop/jnkey.jks')
storePassword '123456'
}
}
buildTypes {
release {
//Zipalign优化
zipAlignEnabled true
// 移除无用的resource文件
shrinkResources false
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
}
sourceSets {
main {
jniLibs.srcDirs = ['libs']
}
}
splits {
abi {
enable true
reset()
include 'armeabi-v7a'
}
}
packagingOptions {
exclude 'META-INF/rxjava.properties'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
exclude 'META-INF/maven.com.squareup.retrofit2.converter-gson/pom.xml'
}
repositories {
flatDir {
dirs 'libs'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:design:25.3.1'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
//compile files('libs/BaiduLBS_Android.jar')
compile files('libs/gson-2.2.4.jar')
compile files('libs/universal-image-loader-1.9.5.jar')
compile 'com.jakewharton:butterknife:7.0.1'
compile 'com.wang.avi:library:2.1.3'
compile 'org.apache.httpcomponents:httpcore:4.4.2'
compile(name: 'AliyunPlayer', ext: 'aar')
compile 'com.android.support:multidex:1.0.1'
compile 'com.tencent.bugly:crashreport:latest.release'
}
~~~
- 环境搭建
- maven的安装
- Eclipse中从svn中检出maven项目
- 升级JDK9后eclipse无法启动解决方法
- Maven教程
- spring-boot
- JAVA基础
- JAVA多线程
- 常见问题
- 怎么解决tomcat占用8080端口问题图文教程
- 保存到数据库中乱码
- idea Tomcat 部署 war和war exploded的区别
- Android
- Android开发之旅:HelloWorld项目的目录结构
- Android Studio 修改包名最便捷做法
- 2017Android学习路线图,内附完整自学视频教程+工具经验
- Android版本更新知识(检测、升级)总结
- Android设备唯一码的获取
- Android Studio配置打包生成自定义文件名
- 多渠道打包之动态修改App名称,图标,applicationId,版本号,添加资源
- JAVA相关技术
- MyBatis 教程
- GUNS后台管理框架
- 相关技术学习集合
- 开源系统
- 技术博客收藏
- Spring MVC
- Spring MVC微博
- SpringMVC 拦截器不拦截静态资源的三种处理方式
- 开发工具
- IntelliJ IDE
- IntelliJ IDEA2017 + tomcat 即改即生效 实现热部署
- IntelliJ IDEA + Tomcat ;On Upate Action 与 On Frame Deactivation
- Shiro
- 跟我学Shiro
- 30分钟学会如何使用Shiro
- shiro.ini 配置详解
- Spring
- 谈谈对Spring IOC的理解
- ConditionalOnProperty的使用
- Tomcat
- Tomcat 部署WAR文件之server.xml Context部署
- Redis
- 使用Jedis源码生成Jedis.jar
- Nutz
- Nutz-book Nutz烹调向导