class Fastlane::Helper::AndroidEnvironment
Attributes
android_home[R]
build_tools_version[R]
Public Class Methods
new(android_home, build_tools_version)
click to toggle source
android_home
- the String path to the install location of the Android SDK build_tools_version
- the String version of the Android build tools that should be used
# File lib/fastlane/plugin/analyze_apk/helper/android_environment.rb, line 13 def initialize(android_home, build_tools_version) @android_home = android_home @build_tools_version = build_tools_version end
Public Instance Methods
aapt_path()
click to toggle source
# File lib/fastlane/plugin/analyze_apk/helper/android_environment.rb, line 22 def aapt_path @aapt_path ||= find_aapt(build_tools_path) end
build_tools_path()
click to toggle source
# File lib/fastlane/plugin/analyze_apk/helper/android_environment.rb, line 18 def build_tools_path @build_tools_path ||= find_build_tools(android_home, build_tools_version) end
Private Instance Methods
executable_command?(cmd_path)
click to toggle source
# File lib/fastlane/plugin/analyze_apk/helper/android_environment.rb, line 67 def executable_command?(cmd_path) cmd_path && File.executable?(cmd_path) && !File.directory?(cmd_path) end
find_aapt(build_tools_path)
click to toggle source
# File lib/fastlane/plugin/analyze_apk/helper/android_environment.rb, line 60 def find_aapt(build_tools_path) return FastlaneCore::CommandExecutor.which('aapt') unless build_tools_path aapt_path = File.join(build_tools_path, 'aapt') executable_command?(aapt_path) ? aapt_path : nil end
find_build_tools(android_home, build_tools_version)
click to toggle source
# File lib/fastlane/plugin/analyze_apk/helper/android_environment.rb, line 28 def find_build_tools(android_home, build_tools_version) return nil unless android_home build_tools_dir = File.join(android_home, 'build-tools') return nil unless build_tools_dir && File.directory?(build_tools_dir) return File.join(build_tools_dir, build_tools_version) if build_tools_version version = select_build_tools_version(build_tools_dir) version ? File.join(build_tools_dir, version) : nil end
select_build_tools_version(build_tools_dir)
click to toggle source
# File lib/fastlane/plugin/analyze_apk/helper/android_environment.rb, line 42 def select_build_tools_version(build_tools_dir) # Collect the sub-directories of the build_tools_dir, rejecting any that start with '.' to remove . and .. dir_names = Dir.entries(build_tools_dir).select { |e| !e.start_with?('.') && File.directory?(File.join(build_tools_dir, e)) } # Collect a sorted array of Version objects from the directory names, handling the possibility that some # entries may not be valid version names versions = dir_names.map do |d| begin Gem::Version.new(d) rescue nil end end.reject(&:nil?).sort # We'll take the last entry (highest version number) as the directory name we want versions.last.to_s end