-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild-android-apk.sh
More file actions
executable file
·62 lines (55 loc) · 1.86 KB
/
Copy pathbuild-android-apk.sh
File metadata and controls
executable file
·62 lines (55 loc) · 1.86 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
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/env bash
# Build the Bitkit Android debug APK from ../bitkit-android and copy into aut/
#
# Inputs/roots:
# - E2E root: this repo (bitkit-e2e-tests)
# - Android root: ../bitkit-android (resolved relative to this script)
#
# Output:
# - Copies dev/regtest debug APK -> aut/bitkit_e2e.apk
# - Copies mainnet debug APK -> aut/bitkit_e2e_mainnet.apk
#
# Requirements:
# - Android SDK/NDK as required by the project, Gradle wrapper
#
# Usage:
# ./scripts/build-android-apk.sh
# BACKEND=regtest ./scripts/build-android-apk.sh
# BACKEND=mainnet ./scripts/build-android-apk.sh
set -euo pipefail
E2E_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
ANDROID_ROOT="$(cd "$E2E_ROOT/../bitkit-android" && pwd)"
BACKEND="${BACKEND:-local}"
E2E_BACKEND="local"
GRADLE_TASK="assembleDevDebug"
APK_FLAVOR_DIR="dev/debug"
OUT_FILENAME="bitkit_e2e.apk"
if [[ "$BACKEND" == "regtest" ]]; then
E2E_BACKEND="network"
elif [[ "$BACKEND" == "local" ]]; then
E2E_BACKEND="local"
elif [[ "$BACKEND" == "mainnet" ]]; then
E2E_BACKEND="network"
GRADLE_TASK="assembleMainnetDebug"
APK_FLAVOR_DIR="mainnet/debug"
OUT_FILENAME="bitkit_e2e_mainnet.apk"
else
echo "ERROR: Unsupported BACKEND value: $BACKEND" >&2
exit 1
fi
echo "Building Android APK (BACKEND=$BACKEND, E2E_BACKEND=$E2E_BACKEND, GRADLE_TASK=$GRADLE_TASK)..."
pushd "$ANDROID_ROOT" >/dev/null
E2E=true E2E_BACKEND="$E2E_BACKEND" ./gradlew "$GRADLE_TASK" --no-daemon --stacktrace
popd >/dev/null
# Find the universal APK
APK_DIR="$ANDROID_ROOT/app/build/outputs/apk/$APK_FLAVOR_DIR"
# shellcheck disable=SC2012
APK_PATH="$(ls -t "$APK_DIR"/bitkit-*-universal.apk 2>/dev/null | head -n 1 || true)"
if [[ ! -f "$APK_PATH" ]]; then
echo "ERROR: APK not found at: $APK_PATH" >&2
exit 1
fi
OUT="$E2E_ROOT/aut"
mkdir -p "$OUT"
cp -f "$APK_PATH" "$OUT/$OUT_FILENAME"
echo "Android APK copied to: $OUT/$OUT_FILENAME (from $(basename "$APK_PATH"))"