android Gradle打包使用教程
2016-05-15 22:59
399 查看
添加依赖:
自定义函数:
配置java编译参数:
dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.android.support:support-v4:22.1.1' compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5' }
自定义函数:
def releaseTime() { return new Date().format("yyyyMMdd", TimeZone.getTimeZone("UTC")) }
配置java编译参数:
compileOptions { sourceCompatibility JavaVersion.VERSION_1_7 targetCompatibility JavaVersion.VERSION_1_7 }
配置签名文件
//配置签名文件 signingConfigs { config { keyAlias 'android' keyPassword '123456' storeFile file('E:/Android文档/keystore/keystore.jks') storePassword '123456' } }
默认配置参数
defaultConfig { applicationId "com.hai" minSdkVersion 17 targetSdkVersion 22 versionCode 1 versionName '1.0' signingConfig signingConfigs.config }
编译types
buildTypes { release { //引用签名配置 signingConfig signingConfigs.config //移除无用的资源文件 minifyEnabled true proguardFile 'E:/Workspace_studio/Test_android/app/proguard-rules.pro' applicationIdSuffix 'release' //版本名后缀 versionNameSuffix 'release' //本地化支持管理 pseudoLocalesEnabled true //zip align优化 zipAlignEnabled true //修改apk文件名 applicationVariants.all { variant -> variant.outputs.each { output -> def outputFile = output.outputFile def fileName = "myapp_v${defaultConfig.versionName}_${releaseTime()}.apk" output.outputFile = new File(outputFile.parent, fileName) } } } }
相关文章推荐
- SourceProvider.getJniDirectories
- 执行失败的任务 ': processDebugManifest'
- Android Studio使用教程(六):Gradle多渠道打包
- Android客户端程序Gradle如何打包
- Android Studio使用教程(四):Gradle基础
- Android Studio使用教程(五):Gradle命令详解和导入第三方包
- Win7安装gradle
- mac gradle 安装
- 关于Android Studio 和 Gradle的那些事儿
- Gradle这个黑盒子
- maven用户试用gradle
- 用Gradle 构建你的android程序
- 用Gradle 构建你的android程序-依赖管理篇
- Gradle 构建 android 应用常见问题解决指南
- Adnroid Studio Gradle 多渠道打包
- Gradle,构建工具的未来?
- Android Studio 使用 Gradle 打包 Jar-IT蓝豹
- gradle安装
- idea使用gradle搭建SpringBoot
- 如何在 Eclipse 下用 Gradle 构建 Web Application