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烹調向導