forked from ZoneMinder/zmNinja
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_android.sh
executable file
·96 lines (77 loc) · 3.62 KB
/
build_android.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/bin/bash
# App signining credentials in this file
NINJAKEYSTORE=~/Desktop/zmNinja.keystore
if [ ! -f "$NINJAKEYSTORE" ]; then
echo "zmNinja keystore not found"
exit
fi
# clean up past builds
rm -fr platforms/android/build/outputs/*
mkdir release_files
rm -f release_files/*
# no arguments - build both
# 1 == build crosswalk only
# 2 == build native only
BUILD_MODE="all"
if [ "$1" = "1" ]; then
BUILD_MODE="xwalk"
echo "only building crosswalk"
fi
if [ "$1" = "2" ]; then
BUILD_MODE="native"
echo "only building native view (5+)"
fi
############ Crosswalk build ####################################
if [ "$BUILD_MODE" = "xwalk" ] || [ "$BUILD_MODE" = "all" ]; then
echo "Building Release mode for Xwalk android..."
echo "--------------------------------------------"
echo "Adding crosswalk..."
#ionic plugin add cordova-plugin-crosswalk-webview --variable "XWALK_VERSION"="18+"
ionic plugin add cordova-plugin-crosswalk-webview
# crosswalk handles SSL certificate handling in a different way
# need to switch plugins
echo "Adding crosswalk cert plugin..."
cordova plugin remove cordova-plugin-certificates
cordova plugin add https://github.com/danjarvis/cordova-plugin-crosswalk-certificate
ionic platform remove android
ionic platform add android
cp "$NINJAKEYSTORE" platforms/android
ionic build android --release
# copy builds to my release directory
cp platforms/android/build/outputs/apk/android-x86-release-unsigned.apk release_files/
cp platforms/android/build/outputs/apk/android-armv7-release-unsigned.apk release_files/
echo "Copied files to release_files"
# sign them
cd release_files/
jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore ../platforms/android/zmNinja.keystore android-armv7-release-unsigned.apk zmNinja
jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore ../platforms/android/zmNinja.keystore android-x86-release-unsigned.apk zmNinja
~/Library/Android/sdk/build-tools/22.0.1/zipalign -v 4 android-x86-release-unsigned.apk zmNinja-x86-pre5.apk
~/Library/Android/sdk/build-tools/22.0.1/zipalign -v 4 android-armv7-release-unsigned.apk zmNinja-arm-pre5.apk
rm -f android-x86-release-unsigned.apk android-armv7-release-unsigned.apk
cd ..
fi
############ Native web view build ###############################
if [ "$BUILD_MODE" = "native" ] || [ "$BUILD_MODE" = "all" ]; then
echo "Building Release mode for android 5+..."
echo "--------------------------------------------"
#clean up past build stuff
rm -fr platforms/android/build/outputs/*
echo "Adding default browser..."
ionic plugin remove cordova-plugin-crosswalk-webview
# use the right plugin for SSL certificate mgmt
cordova plugin remove cordova-plugin-crosswalk-certificate
cordova plugin add https://github.com/hypery2k/cordova-certificate-plugin
ionic platform remove android
ionic platform add android
cp "$NINJAKEYSTORE" platforms/android
# Make sure native builds are only deployed in devices < Android 5
ionic build android --release -- --minSdkVersion=21
# copy build to release folder and sign
cp platforms/android/build/outputs/apk/android-release-unsigned.apk release_files/
echo "Copied files to release_files"
cd release_files/
jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore ../platforms/android/zmNinja.keystore android-release-unsigned.apk zmNinja
~/Library/Android/sdk/build-tools/22.0.1/zipalign -v 4 android-release-unsigned.apk zmNinja.apk
rm -f android-release-unsigned.apk
cd ..
fi