Skip to content

Commit 86625a5

Browse files
committed
fix: android build script
1 parent 1dcf036 commit 86625a5

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

build_android.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ set -e
44
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
55
ANDROID_DIR="${ROOT_DIR}/android"
66
TARGET_DIR=${SND_RELEASE_DIR:="${ROOT_DIR}/build/android"}
7+
# Resolve relative paths against ROOT_DIR so cd operations don't break them
8+
case "${TARGET_DIR}" in
9+
/*) ;;
10+
*) TARGET_DIR="${ROOT_DIR}/${TARGET_DIR}" ;;
11+
esac
712
GRADLE_TASK=${SND_ANDROID_GRADLE_TASK:="assembleDebug"}
813
GRADLE_BIN=${SND_GRADLE:-""}
914
AAR_PATH=${SND_ANDROID_AAR:="${ANDROID_DIR}/app/libs/sndmobile.aar"}
@@ -145,10 +150,19 @@ else
145150
exit 1
146151
fi
147152

153+
cd "${ROOT_DIR}"
154+
148155
echo "Collecting artifacts..."
149156
mkdir -p "${TARGET_DIR}"
150157
find "${ANDROID_DIR}/app/build/outputs" -type f \( -name "*.apk" -o -name "*.aab" \) -exec cp {} "${TARGET_DIR}/" \;
151158

159+
APK_COUNT=$(find "${TARGET_DIR}" -maxdepth 1 -type f \( -name "*.apk" -o -name "*.aab" \) | wc -l | tr -d ' ')
160+
if [ "${APK_COUNT}" -eq 0 ]; then
161+
echo "Error: no APK or AAB files found in ${ANDROID_DIR}/app/build/outputs"
162+
echo "The Gradle build may have failed silently."
163+
exit 1
164+
fi
165+
152166
if [ "${DEPLOY_APK}" = "true" ]; then
153167
require_command adb
154168

0 commit comments

Comments
 (0)