-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathbuild-android-apk.sh
executable file
·90 lines (69 loc) · 2.77 KB
/
build-android-apk.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
#!/bin/bash
set +e
set +o pipefail
EXPLORER_PATH=$(pwd)
if [ ! -d ${EXPLORER_PATH}/godot/android/ ]
then
echo "Checkout godot android template"
git clone -b bump-4.3 https://github.com/decentraland/godot-explorer-android-template ${EXPLORER_PATH}/godot/android
fi
# temp workaround: check if JAVA_HOME is not set
if [ -z "$JAVA_HOME" ]; then
export JAVA_HOME="/usr/lib/jvm/java-17-openjdk-amd64"
fi
echo "Build for Linux x86_64"
cd ${EXPLORER_PATH}
cargo run -- install --platforms android
cargo run -- build
echo "Link export templates"
mkdir -p ${HOME}/.local/share/godot/export_templates/
cd ${HOME}/.local/share/godot/export_templates/
ln -sf ${EXPLORER_PATH}/.bin/godot/templates/templates/ 4.3.stable
set -e
echo "Build for Android (arm64)"
cd ${EXPLORER_PATH}/lib
bash android-build.sh
echo "Build for Android (x86_64)"
cd ${EXPLORER_PATH}/lib
bash android-build.sh x86_64
set +e
echo "Setup Android Debug Keys"
cd /opt/
keytool -keyalg RSA -genkeypair -alias androiddebugkey \
-keypass android -keystore debug.keystore -storepass android \
-dname "CN=Android Debug,O=Android,C=US" -validity 9999 -deststoretype pkcs12
export GODOT_ANDROID_KEYSTORE_DEBUG_PATH=/opt/debug.keystore
export GODOT_ANDROID_KEYSTORE_DEBUG_USER=androiddebugkey
export GODOT_ANDROID_KEYSTORE_DEBUG_PASSWORD=android
cd ${EXPLORER_PATH}/godot/
# Build the .aab without x86_64 architecture
echo "Export Godot android.apk"
# Define the command to be executed
COMMAND="${EXPLORER_PATH}/.bin/godot/godot4_bin -e --headless --export-debug android ${EXPLORER_PATH}/android.apk"
# Try executing the command
if ! $COMMAND; then
echo "First attempt failed, retrying in 5 seconds..."
sleep 5 # Wait for 5 seconds before retrying
# Retry executing the command
if ! $COMMAND; then
echo "Second attempt failed."
else
echo "Second attempt succeeded."
fi
else
echo "First attempt succeeded."
fi
${EXPLORER_PATH}/.bin/godot/godot4_bin -e --headless --export-debug quest ${EXPLORER_PATH}/meta-quest.apk || true
# Build the .aab without x86_64 architecture
echo "Setting up to export godot .aab"
# Use aab
sed -i 's/gradle_build\/export_format=0/gradle_build\/export_format=1/' ${EXPLORER_PATH}/godot/export_presets.cfg
# remove x86_64
sed -i 's/architectures\/x86_64=true/architectures\/x86_64=false/' ${EXPLORER_PATH}/godot/export_presets.cfg
# remove signed
sed -i 's/package\/signed=true/package\/signed=false/' ${EXPLORER_PATH}/godot/export_presets.cfg
# Build the .aab without x86_64 architecture
echo "Export Godot AAB"
${EXPLORER_PATH}/.bin/godot/godot4_bin -e --headless --export-release android ${EXPLORER_PATH}/android-unsigned.aab || true
${EXPLORER_PATH}/.bin/godot/godot4_bin -e --headless --export-release quest ${EXPLORER_PATH}/meta-quest-unsigned.aab || true
echo "Finished"