Skip to content

Update Android SDK packages in macOS setup script #2857

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 30, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 11 additions & 20 deletions setup/native-script.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,7 @@ def install_environment_variable(name, value)

unless ENV["ANDROID_HOME"]
require 'pathname'
# if android-sdk was installed through brew, there should be a symlink in /usr/local/opt/android-sdk pointing to the actual sdk
android_home = "/usr/local/opt/android-sdk"
android_home = "/usr/local/share/android-sdk"
unless Pathname.new(android_home).exist?
require 'mkmf'
# if there's no such symlink then try to find the `android-sdk` directory through the `android` executable
Expand Down Expand Up @@ -129,32 +128,24 @@ def install_environment_variable(name, value)
# the android tool will introduce a --accept-license option in subsequent releases
error_msg = "There seem to be some problems with the Android configuration"

android_executable = File.join(ENV["ANDROID_HOME"], "tools", "bin", "sdkmanager")
execute("echo y | #{android_executable} \"platform-tools\"", error_msg)
execute("echo y | #{android_executable} \"tools\"", error_msg)
execute("echo y | #{android_executable} \"build-tools;25.0.2\"", error_msg)
execute("echo y | #{android_executable} \"platforms;android-25\"", error_msg)
execute("echo y | #{android_executable} \"platforms;android-24\"", error_msg)
execute("echo y | #{android_executable} \"platforms;android-23\"", error_msg)
execute("echo y | #{android_executable} \"platforms;android-22\"", error_msg)
execute("echo y | #{android_executable} \"platforms;android-21\"", error_msg)
execute("echo y | #{android_executable} \"platforms;android-19\"", error_msg)
execute("echo y | #{android_executable} \"platforms;android-18\"", error_msg)
execute("echo y | #{android_executable} \"platforms;android-17\"", error_msg)
sdk_manager = File.join(ENV["ANDROID_HOME"], "tools", "bin", "sdkmanager")
execute("echo y | #{sdk_manager} \"platform-tools\"", error_msg)
execute("echo y | #{sdk_manager} \"tools\"", error_msg)
execute("echo y | #{sdk_manager} \"build-tools;25.0.2\"", error_msg)
execute("echo y | #{sdk_manager} \"platforms;android-23\"", error_msg)
execute("echo y | #{sdk_manager} \"extras;android;m2repository\"", error_msg)
execute("echo y | #{sdk_manager} \"extras;google;m2repository\"", error_msg)

puts "Do you want to install Android emulator? (y/n)"
if gets.chomp.downcase == "y"
puts "Do you want to install HAXM (Hardware accelerated Android emulator)? (y/n)"
if gets.chomp.downcase == "y"
execute("echo y | #{android_executable} \"extras;intel;Hardware_Accelerated_Execution_Manager\"", error_msg)

execute("echo y | #{sdk_manager} \"extras;intel;Hardware_Accelerated_Execution_Manager\"", error_msg)
haxm_silent_installer = File.join(ENV["ANDROID_HOME"], "extras", "intel", "Hardware_Accelerated_Execution_Manager", "silent_install.sh")
execute("sudo #{haxm_silent_installer}", "There seem to be some problems with the Android configuration")
else
end
execute("echo y | #{android_executable} \"system-images;android-25;google_apis;x86\"", error_msg)
execute("echo y | #{android_executable} \"system-images;android-24;default;x86\"", error_msg)
execute("echo y | #{sdk_manager} \"system-images;android-23;default;x86\"", error_msg)
end

puts "The ANDROID_HOME and JAVA_HOME environment variables have been added to your .bash_profile/.zprofile"
puts "Restart the terminal or run `source ~/.bash_profile` to use them."
puts "Restart the terminal or run `source ~/.bash_profile` to use them."