最近要进行打包全自动化,把打渠道包的功能也给运营来做,所以要把打渠道包的事情转移到服务器上,
默认 本机支持如下命令: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.apkexport workfiledir=$1export originApkPath=$2export SignApkPath=$ANDROID_HOME/tools/SignApk.jarecho $workfiledirecho $originApkPathfunction 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;