Skip to content

Commit

Permalink
pass adb command dynamically (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
nemanjar7 authored Dec 20, 2024
1 parent 531dec6 commit 7c5b789
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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?
Expand All @@ -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
Expand Down Expand Up @@ -98,14 +98,16 @@ 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?
UI.user_error!("Error: APK file not found in build outputs.")
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

Expand Down

0 comments on commit 7c5b789

Please sign in to comment.