@@ -39,7 +39,7 @@ Commands:
3939 emulator reset Reset all emulator AVDs
4040 app status Check if deployed app is running
4141 app stop Stop the deployed app
42- run [apk_path ] [device] Start emulator, install, and launch app
42+ run [--apk path ] [-- device name] Start emulator, install, and launch app
4343
4444Examples:
4545 android.sh deploy
@@ -55,8 +55,8 @@ Examples:
5555 android.sh app stop
5656 android.sh run # Start emulator, install, launch
5757 android.sh run max # Same, but on 'max' device
58- android.sh run path/to/app.apk # Install provided APK
59- android.sh run path/to/ app.apk max # Install APK on 'max' device
58+ android.sh run --apk path/to/app.apk # Install provided APK
59+ android.sh run --apk app.apk --device max # Install APK on 'max' device
6060
6161Note: Configuration is managed via environment variables in devbox.json.
6262Note: Build your app with gradle directly (e.g., cd android && ./gradlew assembleDebug)
@@ -536,23 +536,32 @@ case "$command_name" in
536536
537537 # --------------------------------------------------------------------------
538538 # run - Build, install, and launch app on emulator
539- # Usage: android.sh run [apk_path ] [device]
539+ # Usage: android.sh run [--apk <path>] [--device <name> ] [device]
540540 # --------------------------------------------------------------------------
541541 run)
542- # Parse arguments - first arg could be APK path or device name
542+ # Parse arguments
543543 apk_arg=" "
544544 device_name=" "
545545
546- if [ $# -gt 0 ]; then
547- # If first arg looks like a file path (contains / or ends with .apk), treat as APK
548- if printf ' %s' " $1 " | grep -q -e ' /' -e ' \.apk$' ; then
549- apk_arg=" $1 "
550- shift
551- fi
552- fi
553-
554- # Remaining arg is device name
555- device_name=" ${1:- } "
546+ while [ $# -gt 0 ]; do
547+ case " $1 " in
548+ --apk)
549+ apk_arg=" ${2:- } "
550+ shift 2
551+ ;;
552+ --device)
553+ device_name=" ${2:- } "
554+ shift 2
555+ ;;
556+ * )
557+ # Bare positional arg: treat as device name for convenience
558+ if [ -z " $device_name " ]; then
559+ device_name=" $1 "
560+ fi
561+ shift
562+ ;;
563+ esac
564+ done
556565
557566 # Source layer 3 dependencies
558567 avd_script=" ${scripts_dir%/ } /domain/avd.sh"
@@ -591,12 +600,16 @@ case "$command_name" in
591600 android_start_emulator " $device_name "
592601
593602 echo " "
594- # Pass both APK (if provided) and device name to run
603+ # Pass both APK (if provided) and device name to run with explicit flags
604+ run_args=" "
595605 if [ -n " $apk_arg " ]; then
596- android_run_app " $apk_arg " " $device_name "
597- else
598- android_run_app " $device_name "
606+ run_args=" --apk $apk_arg "
607+ fi
608+ if [ -n " $device_name " ]; then
609+ run_args=" $run_args --device $device_name "
599610 fi
611+ # shellcheck disable=SC2086
612+ android_run_app $run_args
600613 ;;
601614
602615 # --------------------------------------------------------------------------
0 commit comments