android 批量打包
2016-04-26 16:41
447 查看
由于公司有一百多个渠道,需要一百多个包,使用eclipse打包,不用说大家就知道我的感受了,一个人3天什么事也不做,关键是这活一点技术含量也没有,没意思,实在没办法批量打包吧!
1 工具intellij idea
2 把原来的代码转移至idea项目中,删除多余的代码
3 编译,如果图片出错,用工具转一下(ImageMagick Display)
4 配置资源
gradle 文件:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath ‘com.android.tools.build:gradle:1.3.1’
}
}
apply plugin: ‘com.android.application’
repositories {
mavenCentral()
mavenLocal()
flatDir {
dirs ‘libs’
}
maven {
url “https://oss.sonatype.org/content/repositories/snapshots/”
}
}
android {
compileSdkVersion 23
buildToolsVersion “23.0.2”
}
dependencies {
compile fileTree(dir: ‘libs’, include: [‘*.jar’])
}
def product_name = “v” + android.defaultConfig.versionName
def time = “3000”
task initTimeScape << {
println “first time”
println “time”defgCalendar=newGregorianCalendar()time=gCalendar.time.format(“MMddHHmm”)println“secondtime”println“time”
def gCalendar = new GregorianCalendar()
time = gCalendar.time.format(“MMddHHmm”)
println “second time”
println “time”
}
task initReleaseApkProduct_name(dependsOn: [‘initTimeScape’]) << {
//初始化release包名
product_name = product_name + “_” + time + “R.apk”
def outputName = “OUT:>PRODUCT_FILENAME=” + product_name + “;”
println “$outputName”
}
task initDebugApkProduct_name(dependsOn: [‘initTimeScape’]) << { //初始化release包名
product_name = product_name + “_” + time + “D.apk”
def outputName = “OUT:>PRODUCT_FILENAME=” + product_name + “;”
println “$outputName”
}
task release(dependsOn: [‘assembleRelease’, ‘initReleaseApkProduct_name’]) << {
copy {
from(‘build/outputs/apk’) {
include(‘*/-release.apk’)
rename ‘(.*)-release.apk’, product_name
}
from(‘build/proguard/release’) {
include(‘**/mapping.txt’)
rename ‘(.*).txt’, product_name + “.map”
}
into(‘products’)
}
}
task debug(dependsOn: [‘assembleDebug’, ‘initDebugApkProduct_name’]) << {
copy {
from(‘build/outputs/apk’) {
include(‘*/.apk’)
rename ‘(.*).apk’, product_name
}
into(‘products’)
}
}
资源配置:
src下和main同目录,创建包,抽取不同的资源,特别注意向,对于自定义的view,命名空间需要改一下。
clean —> release
1 工具intellij idea
2 把原来的代码转移至idea项目中,删除多余的代码
3 编译,如果图片出错,用工具转一下(ImageMagick Display)
4 配置资源
gradle 文件:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath ‘com.android.tools.build:gradle:1.3.1’
}
}
apply plugin: ‘com.android.application’
repositories {
mavenCentral()
mavenLocal()
flatDir {
dirs ‘libs’
}
maven {
url “https://oss.sonatype.org/content/repositories/snapshots/”
}
}
android {
compileSdkVersion 23
buildToolsVersion “23.0.2”
productFlavors { xxxxx1{ manifestPlaceholders = [ CHANNEL_NAME:"com.xxx.xxx"] applicationId "com.xxx.xxx" } xxxxx2 { manifestPlaceholders = [ CHANNEL_NAME:"com.xxx.xxx"] applicationId "com.xxx.xxx" } xxxxx3 { manifestPlaceholders = [ CHANNEL_NAME:"com.xxx.xxx"] applicationId "com.xxx.xxx" } xxxxx4{ manifestPlaceholders = [ CHANNEL_NAME:"com.xxx.xxx"] applicationId "com.xxx.xxx" } xxxxx5{ manifestPlaceholders = [ CHANNEL_NAME:"com.xxx.xxx"] applicationId "com.xxx.xxx" } xxxxx6 { manifestPlaceholders = [ CHANNEL_NAME:"com.xxx.xxx"] applicationId "com.xxx.xxx" } xxxxx7{ manifestPlaceholders = [ CHANNEL_NAME:"com.xxx.xxx"] applicationId "com.xxx.xxx" } } lintOptions { abortOnError false } defaultConfig { applicationId "com.xxx.xxx" minSdkVersion 14 targetSdkVersion 22 versionCode 30 versionName "3.2.0" } compileOptions { sourceCompatibility JavaVersion.VERSION_1_7 targetCompatibility JavaVersion.VERSION_1_7 } //打包签名 signingConfigs { myConfig { storeFile file("xxx.keystore") storePassword "xxx" keyAlias "xxx" keyPassword "xxx" } } buildTypes { release { signingConfig signingConfigs.myConfig minifyEnabled true zipAlignEnabled true proguardFiles 'proguard-rules.pro' } }
}
dependencies {
compile fileTree(dir: ‘libs’, include: [‘*.jar’])
}
def product_name = “v” + android.defaultConfig.versionName
def time = “3000”
task initTimeScape << {
println “first time”
println “time”defgCalendar=newGregorianCalendar()time=gCalendar.time.format(“MMddHHmm”)println“secondtime”println“time”
def gCalendar = new GregorianCalendar()
time = gCalendar.time.format(“MMddHHmm”)
println “second time”
println “time”
}
task initReleaseApkProduct_name(dependsOn: [‘initTimeScape’]) << {
//初始化release包名
product_name = product_name + “_” + time + “R.apk”
def outputName = “OUT:>PRODUCT_FILENAME=” + product_name + “;”
println “$outputName”
}
task initDebugApkProduct_name(dependsOn: [‘initTimeScape’]) << { //初始化release包名
product_name = product_name + “_” + time + “D.apk”
def outputName = “OUT:>PRODUCT_FILENAME=” + product_name + “;”
println “$outputName”
}
task release(dependsOn: [‘assembleRelease’, ‘initReleaseApkProduct_name’]) << {
copy {
from(‘build/outputs/apk’) {
include(‘*/-release.apk’)
rename ‘(.*)-release.apk’, product_name
}
from(‘build/proguard/release’) {
include(‘**/mapping.txt’)
rename ‘(.*).txt’, product_name + “.map”
}
into(‘products’)
}
}
task debug(dependsOn: [‘assembleDebug’, ‘initDebugApkProduct_name’]) << {
copy {
from(‘build/outputs/apk’) {
include(‘*/.apk’)
rename ‘(.*).apk’, product_name
}
into(‘products’)
}
}
资源配置:
src下和main同目录,创建包,抽取不同的资源,特别注意向,对于自定义的view,命名空间需要改一下。
clean —> release
相关文章推荐
- Android Layout XML属性
- [Android]手机短信验证功能
- 15 个必知的 Android 开发者选项
- Android与H5数据交互
- Android 6.0运行时权限解决办法
- 新思路_Android同时显示多个跑马灯
- 超实用的Android手势锁制作实例教程
- Android的SharedPreferences和PreferenceActivity用法
- Android this document contains very long lines
- Android成长之路(4)——Activity的生命周期(2)
- Android高可拓展框架Conductor源码解析(2)
- Android横竖屏切换总结(Android资料)
- android studio debug签名设置
- android横竖屏切换时Activity的生命周期
- Android 4.4 Kitkat Phone工作流程浅析(四)__RILJ工作流程简析
- Android开发者必知的开发资源
- android studio打.so文件遇到的问题
- android 控件 下拉刷新 Android-PullToRefresh
- Android Studio如何打包APK与查看打包后的SHA1
- Android App中ListView仿QQ实现滑动删除效果的要点解析