From 7c5b78939bf44c71319838c6de3950f51383987f Mon Sep 17 00:00:00 2001 From: nemanjar7 Date: Fri, 20 Dec 2024 16:42:53 -0500 Subject: [PATCH] pass adb command dynamically (#8) --- .../actions/maestro_orchestration_android_action.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/fastlane/plugin/maestro_orchestration/actions/maestro_orchestration_android_action.rb b/lib/fastlane/plugin/maestro_orchestration/actions/maestro_orchestration_android_action.rb index 1b80845..69540d5 100644 --- a/lib/fastlane/plugin/maestro_orchestration/actions/maestro_orchestration_android_action.rb +++ b/lib/fastlane/plugin/maestro_orchestration/actions/maestro_orchestration_android_action.rb @@ -26,7 +26,7 @@ def self.run(params) install_android_app(params) UI.message("Running Maestro tests on Android...") - devices = `adb devices`.split("\n").drop(1) + devices = `#{adb} devices`.split("\n").drop(1) if devices.empty? UI.message("No running emulators found.") else @@ -53,7 +53,7 @@ def self.setup_emulator(params) adb = "#{sdk_dir}/platform-tools/adb" UI.message("Stop all running emulators...") - devices = `adb devices`.split("\n").drop(1) + devices = `#{adb} devices`.split("\n").drop(1) UI.message("Devices: #{devices}") if devices.empty? @@ -63,7 +63,7 @@ def self.setup_emulator(params) devices.each do |device| serial = device.split("\t").first # Extract the serial number if serial.include?("emulator") # Check if it's an emulator - system("adb -s #{serial} emu kill") # Stop the emulator + system("#{adb} -s #{serial} emu kill") # Stop the emulator system("Stopped emulator: #{serial}") end end @@ -98,6 +98,8 @@ def self.demo_mode(params) def self.install_android_app(params) UI.message("Installing Android app...") + sdk_dir = params[:sdk_dir] + adb = "#{sdk_dir}/platform-tools/adb" apk_path = Dir["app/build/outputs/apk/release/app-release.apk"].first if apk_path.nil? @@ -105,7 +107,7 @@ def self.install_android_app(params) end UI.message("Found APK file at: #{apk_path}") - sh("adb install -r '#{apk_path}'") + sh("#{adb} install -r '#{apk_path}'") UI.success("APK installed on Android emulator.") end