Skip to content

Commit 39391a8

Browse files
antonisclaude
andcommitted
refactor(e2e): Consolidate Android build scripts per review feedback
Replaces separate build-android-debug-auto.sh and build-android-debug-manual.sh scripts with a single consolidated build-android-debug-init.sh that validates SENTRY_DISABLE_NATIVE_START and provides clear error messages. Key improvements: - Single source of truth for Android build logic - Environment variable validation with helpful error messages - Maps true/false to auto/manual build modes - Dynamic APK naming based on mode - Error handling if APK not found Package.json now calls the script directly with the env var inline, eliminating the need for wrapper scripts while maintaining the same developer ergonomics (yarn build-android-debug-auto/manual still work). Addresses review feedback from lucas-zimerman at: #5583 (comment) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 112bfc6 commit 39391a8

File tree

4 files changed

+49
-46
lines changed

4 files changed

+49
-46
lines changed

samples/react-native/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
"build-android-release-legacy": "scripts/build-android-release-legacy.sh",
1111
"build-android-debug": "scripts/build-android-debug.sh",
1212
"build-android-debug-legacy": "scripts/build-android-debug-legacy.sh",
13-
"build-android-debug-auto": "scripts/build-android-debug-auto.sh",
14-
"build-android-debug-manual": "scripts/build-android-debug-manual.sh",
13+
"build-android-debug-auto": "SENTRY_DISABLE_NATIVE_START=true scripts/build-android-debug-init.sh",
14+
"build-android-debug-manual": "SENTRY_DISABLE_NATIVE_START=false scripts/build-android-debug-init.sh",
1515
"build-ios-release": "scripts/build-ios-release.sh",
1616
"build-ios-debug": "scripts/build-ios-debug.sh",
1717
"test": "jest",

samples/react-native/scripts/build-android-debug-auto.sh

Lines changed: 0 additions & 22 deletions
This file was deleted.
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/bin/bash
2+
3+
# Exit on error
4+
set -e
5+
6+
thisFilePath=$(dirname "$0")
7+
8+
# Validate SENTRY_DISABLE_NATIVE_START is set
9+
if [ -z "${SENTRY_DISABLE_NATIVE_START}" ]; then
10+
echo "Error: SENTRY_DISABLE_NATIVE_START environment variable is not set."
11+
echo "Usage: SENTRY_DISABLE_NATIVE_START=true|false $0"
12+
echo ""
13+
echo " true - Build for auto init from JS (native SDK disabled)"
14+
echo " false - Build for manual native init (native SDK enabled)"
15+
exit 1
16+
fi
17+
18+
# Map SENTRY_DISABLE_NATIVE_START to build mode
19+
if [ "${SENTRY_DISABLE_NATIVE_START}" = "true" ]; then
20+
BUILD_MODE="auto"
21+
INIT_DESCRIPTION="initialize Sentry from JavaScript (auto init)"
22+
elif [ "${SENTRY_DISABLE_NATIVE_START}" = "false" ]; then
23+
BUILD_MODE="manual"
24+
INIT_DESCRIPTION="initialize Sentry natively before JS (manual init)"
25+
else
26+
echo "Error: Invalid value for SENTRY_DISABLE_NATIVE_START: '${SENTRY_DISABLE_NATIVE_START}'"
27+
echo "Expected 'true' or 'false'"
28+
exit 1
29+
fi
30+
31+
export RN_ARCHITECTURE="new"
32+
export CONFIG="debug"
33+
34+
echo "Building Android with SENTRY_DISABLE_NATIVE_START=${SENTRY_DISABLE_NATIVE_START}"
35+
echo "This build will ${INIT_DESCRIPTION}"
36+
37+
"${thisFilePath}/build-android.sh"
38+
39+
# Rename the output APK based on build mode
40+
cd "${thisFilePath}/.."
41+
if [ -f "app.apk" ]; then
42+
mv app.apk "app-${BUILD_MODE}.apk"
43+
echo "Build complete: app-${BUILD_MODE}.apk"
44+
else
45+
echo "Error: Expected output file 'app.apk' not found"
46+
exit 1
47+
fi

samples/react-native/scripts/build-android-debug-manual.sh

Lines changed: 0 additions & 22 deletions
This file was deleted.

0 commit comments

Comments
 (0)