MoSync 自动打包apk ,首先配置MoSync 的环境变量
终端执行
#touch .bash_profile
#open .bash_profile
弹出文本 输入 MOMOSYNCDIR = /Applications/MoSync
#source .bash_profile
查看环境变量
#echo $MOMOSYNCDIR
然后将以下脚本放在工程目录下,执行就可以了
#!/bin/bash
#----------------------------------------------------------------------------------------
# if error : MOSYNCDIR is not set
#touch .bash_profile
#open .bash_profile MOMOSYNCDIR = /Applications/MoSync
#source .bash_profile
#echo $MOMOSYNCDIR
#-----------------------------------------------------------------------------------------
PROJECT_PATH=$(pwd)
echo $PROJECT_PATH
PROJECT_NAME=${PROJECT_PATH##*/}
echo $PROJECT_NAME
/Applications/MoSync/bin/Bundle -in $PROJECT_PATH/LocalFiles -out $PROJECT_PATH/Resources/LocalFiles.bin
/Applications/MoSync/bin/pipe-tool -appcode=JCYQ -R -depend=$PROJECT_PATH/Output/Release/Android/Android/resources.deps $PROJECT_PATH/Output/Release/Android/Android/resources $PROJECT_PATH/Resources/Resources.lst
/Applications/MoSync/bin/xgcc -o $PROJECT_PATH/Output/Release/Android/Android/main.s -S -g -MMD -MF $PROJECT_PATH/Output/Release/Android/Android/main.s.deps -Wall -Werror -DMAPIP -O2 -DPLATFORM_ANDROID -DVARIANT_ANDROID_ANDROID $PROJECT_PATH/main.cpp -I/Applications/MoSync/include -I$PROJECT_PATH/Output/Release/Android/Android
/Applications/MoSync/bin/pipe-tool -appcode=JCYQ -stabs=stabs.tab -heapsize=3145728 -stacksize=524288 -datasize=4194304 -sld=sld.tab -s/Applications/MoSync/lib/pipe -B $PROJECT_PATH/Output/Release/Android/Android/program $PROJECT_PATH/Output/Release/Android/Android/main.s mastd.lib MAUtil.lib NativeUI.lib MAFS.lib Wormhole.lib yajl.lib Notification.lib
/Applications/MoSync/bin/android/zipalign -f 4 $PROJECT_PATH/Output/Release/Android/Android/package/${PROJECT_NAME}_unaligned.apk $PROJECT_PATH/Output/Release/Android/Android/package/${PROJECT_NAME}.apk
/Applications/MoSync/bin/package -t platform -p $PROJECT_PATH/Output/Release/Android/Android/program -r $PROJECT_PATH/Output/Release/Android/Android/resources -i /Applications/MoSync/etc/default.icon -d $PROJECT_PATH/Output/Release/Android/Android/package -m Android/Android --vendor BuiltWithMoSyncSDK -n ${PROJECT_NAME} --version 1.0 --permissions "File Storage,File Storage/Read,File Storage/Write,Internet Access,Internet Access/HTTPS,Vibration" --android-package com.mosync.app_${PROJECT_NAME} --android-version-code 1 --android-keystore /Applications/MoSync/etc/mosync.keystore --android-storepass ***HIDDEN*** --android-alias mosync.keystore --android-keypass ***HIDDEN*** --android-install-location internalOnly
#/Applications/MoSync/bin/android/zipalign -f 4 $PROJECT_PATH/Output/Release/Android/Android/package/${PROJECT_NAME}_unaligned.apk $PROJECT_PATH/Output/Release/Android/Android/package/${PROJECT_NAME}.apk