批量打渠道包

Posted 身带吴钩

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了批量打渠道包相关的知识,希望对你有一定的参考价值。

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


默认 本机支持如下命令: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;

  

以上是关于批量打渠道包的主要内容,如果未能解决你的问题,请参考以下文章

Unity3D脚本批量打包渠道包

简单快速的Android打渠道包的方法

app应用市场下载统计攻略

android gradle 实例教程一(同时打多渠道包)

Android Studio多渠道批量打包及代码混淆

巧用openinstall,告别多渠道打包