-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathbuild_and_run.sh
More file actions
executable file
·36 lines (30 loc) · 1022 Bytes
/
Copy pathbuild_and_run.sh
File metadata and controls
executable file
·36 lines (30 loc) · 1022 Bytes
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
#!/bin/bash
# Linux version of build_and_run.cmd
# Set Android environment variables
# Adjust these paths according to your Android SDK installation
export ANDROID_HOME="$HOME/Android/Sdk"
export ANDROID_SDK_ROOT="$ANDROID_HOME"
export PATH="$PATH:$ANDROID_HOME/platform-tools:$ANDROID_HOME/emulator"
# Wait for the emulator to fully boot
echo "Waiting for emulator to boot..."
wait_for_boot() {
adb wait-for-device
while [[ "$(adb shell getprop sys.boot_completed 2>/dev/null | tr -d '\r')" != "1" ]]; do
echo "Still booting..."
sleep 2
done
}
wait_for_boot
# Additional wait to ensure Flutter can detect it
echo "Emulator booted, waiting for Flutter detection..."
sleep 10
# Run the Flutter app
echo "Running Flutter app..."
EMULATOR_ID=$(adb devices | grep emulator | head -n1 | cut -f1)
if [[ -n "$EMULATOR_ID" ]]; then
echo "Running Flutter app on $EMULATOR_ID..."
flutter run -d "$EMULATOR_ID"
else
echo "No emulator found. Please start an emulator first."
exit 1
fi