Repository navigation
Expand file tree
/
Copy pathbuild-aab.sh
More file actions
50 lines (42 loc) · 1.5 KB
/
Copy pathbuild-aab.sh
File metadata and controls
50 lines (42 loc) · 1.5 KB
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
#!/bin/bash
function err_and_exit()
{
echo "$1" >&2
exit 1
}
function getVersionName()
{
echo $(grep versionName ./app/build.gradle.kts | awk -F '"' '{print $2}')
}
sed -i -e '/READ_SMS/d' ./app/src/main/AndroidManifest.xml
sed -i -e '/SEND_SMS/d' ./app/src/main/AndroidManifest.xml
sed -i -e '/READ_CALL_LOG/d' ./app/src/main/AndroidManifest.xml
sed -i -e '/WRITE_CALL_LOG/d' ./app/src/main/AndroidManifest.xml
sed -i -e '/REQUEST_INSTALL_PACKAGES/d' ./app/src/main/AndroidManifest.xml
sed -i -e '/QUERY_ALL_PACKAGES/d' ./app/src/main/AndroidManifest.xml
sed -i -e '/REQUEST_DELETE_PACKAGES/d' ./app/src/main/AndroidManifest.xml
perl -i -0pe 's/\n\s+<service\n[^<]*\.services\.PlainAccessibilityService[\s\S]*?<\/service>//g' ./app/src/main/AndroidManifest.xml
cat > ./keystore.properties <<EOF
storePassword=$ANDROID_STORE_PASSWORD
keyPassword=$ANDROID_KEY_PASSWORD
keyAlias=release
storeFile=release.jks
EOF
if [ -n "$ANDROID_HOME" ]; then
SDK_DIR="$ANDROID_HOME"
elif [ -d "$HOME/Library/Android/sdk" ]; then
SDK_DIR="$HOME/Library/Android/sdk"
else
SDK_DIR="/usr/local/lib/android/sdk"
fi
cat > ./local.properties <<EOF
sdk.dir=$SDK_DIR
EOF
cat > ./app/play-config.json <<EOF
$PLAY_STORE_CONFIG_JSON
EOF
# Only the googleRelease bundle is needed; bundleRelease would also build
# the unused github flavor.
./gradlew :app:bundleGoogleRelease || err_and_exit "build failed"
BUILD_FILE="PlainApp-$(getVersionName)-Google-Play.aab"
mv ./app/build/outputs/bundle/googleRelease/app-google-release.aab $BUILD_FILE