forked from bplaat/coinlist-android
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·59 lines (46 loc) · 2.16 KB
/
build.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
#!/bin/bash
# The default gradle Android build toolchain is slow on my old laptop and produces bloated apks
# So I use this bullshit build script to get the job done!
PATH=$PATH:~/android-sdk/build-tools/30.0.3:~/android-sdk/platform-tools
PLATFORM=~/android-sdk/platforms/android-30/android.jar
name="coinlist"
package="ml.coinlist.android"
password="android"
if [ "$1" == "key" ]; then
keytool -genkey -validity 7120 -keystore keystore.jks -keyalg RSA -keysize 4096 -storepass $password -keypass $password
elif [ "$1" == "log" ]; then
adb logcat -c
adb logcat *:E
elif [ "$1" == "clear" ]; then
adb shell pm clear $package
adb shell am start -n $package/.MainActivity
else
mkdir res-compiled
if aapt2 compile --dir res -o res-compiled; then
if aapt2 link res-compiled/*.flat --manifest AndroidManifest.xml --java src -I $PLATFORM -o $name-unaligned.apk; then
mkdir src-compiled
find src -name *.java > sources.txt
if javac -Xlint -cp $PLATFORM -d src-compiled @sources.txt; then
find src-compiled -name *.class > classes.txt
if [ "$(uname -s)" == "Linux" ]; then
d8 --release --lib $PLATFORM --min-api 21 @classes.txt
else
d8.bat --release --lib $PLATFORM --min-api 21 @classes.txt
fi
aapt add $name-unaligned.apk classes.dex > /dev/null
zipalign -f -p 4 $name-unaligned.apk $name.apk
if [ "$(uname -s)" == "Linux" ]; then
apksigner sign --v4-signing-enabled false --ks keystore.jks --ks-pass pass:$password --ks-pass pass:$password $name.apk
else
apksigner.bat sign --v4-signing-enabled false --ks keystore.jks --ks-pass pass:$password --ks-pass pass:$password $name.apk
fi
adb install -r $name.apk
adb shell am start -n $package/.MainActivity
rm -f classes.txt classes.dex
fi
rm -f -r src-compiled sources.txt
fi
rm -f -r $name-unaligned.apk src/${package//\./\/}/R.java
fi
rm -f -r res-compiled
fi