码迷,mamicode.com
首页 > 其他好文 > 详细

批量打渠道包

时间:2016-10-14 17:37:24      阅读:187      评论:0      收藏:0      [点我收藏+]

标签:

最近要进行打包全自动化,把打渠道包的功能也给运营来做,所以要把打渠道包的事情转移到服务器上,


默认 本机支持如下命令:java,7z,zipalign
*.keystore 和 SignApk.jar 在 ANDROID_HOME\tools\ 文件夹下
参数1:工作目录,参数2:源apk路径
useage: ./channelbuild.sh D:\\ C:\\Users\\13051041\\Desktop\\sign\\test.apk
注意你需要设置下keystore的位置和渠道号

 

#!/bin/sh
#Author:wuchenjie(13051041),DATE:2016/10/14
# 默认 本机支持如下命令:java,7z,zipalign
# *.keystore 和 SignApk.jar 在 ANDROID_HOME\tools\ 文件夹下
# 参数1:工作目录,参数2:源apk路径
# useage: ./channelbuild.sh  D:\\ C:\\Users\\13051041\\Desktop\\sign\\test.apk
# 注意你需要设置下keystore的位置和渠道号

#keysrote 的位置
export suningKeystorePath=$ANDROID_HOME/tools/*.keystore
#渠道号:
declare -A channels=(["360"]="360" ["baidu"]="baidu" ["androidSC"]="androidSC" ["测试中文"]="测试中文")

export key=*
export storepass=*
export keypass=*
export unsignedapk=* export signedapk=* export releaseapk=release.apk export workfiledir=$1 export originApkPath=$2 export SignApkPath=$ANDROID_HOME/tools/SignApk.jar echo $workfiledir echo $originApkPath function readyTempApk(){ rm -rf $workfiledir/tmp; rm -rf $workfiledir/out; mkdir $workfiledir/tmp; mkdir -p $workfiledir/tmp/assets; cp $originApkPath $workfiledir/tmp/suning_tmp.apk; echo $originApkPath echo $workfiledir/tmp/suning_tmp.apk 7z d $workfiledir/tmp/suning_tmp.apk META-INF; } function buildingApk(){ echo "***********************building start*******************************" cp $workfiledir/tmp/config_channel.txt $workfiledir/tmp/assets/config_channel.txt; cp $workfiledir/tmp/suning_tmp.apk $workfiledir/tmp/$unsignedapk; cd $workfiledir/tmp pwd 7z a $workfiledir/tmp/$unsignedapk assets/config_channel.txt; cd $workfiledir java -jar $SignApkPath $suningKeystorePath $storepass suning $keypass $workfiledir/tmp/$unsignedapk $workfiledir/tmp/$signedapk zipalign -v 4 $workfiledir/tmp/$signedapk $workfiledir/tmp/$releaseapk; rm $workfiledir/tmp/$unsignedapk; rm $workfiledir/tmp/$signedapk; echo "***********************building end***********************************************" } function loopthoughChannel(){ for key in ${!channels[@]} do rm -rf $workfiledir/tmp/config_channel.txt; echo \{\"CHANNEL_ID\":\"$key\",\"CHANNEL_NAME\":\"${channels[$key]}\"\} >> $workfiledir/tmp/config_channel.txt; buildingApk; mkdir -p $workfiledir/out/${channels[$key]} echo $workfiledir/out/${channels[$key]}/${channels[$key]}"-suning-release.apk" mv $workfiledir/tmp/$releaseapk $workfiledir/out/${channels[$key]}/${channels[$key]}"-suning-release.apk" done } readyTempApk; loopthoughChannel;

  注意,有编码格式的问题,我上传个附件是linux环境下的:http://files.cnblogs.com/files/chenjie0949/channelbuild.sh

批量打渠道包

标签:

原文地址:http://www.cnblogs.com/chenjie0949/p/5960939.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!