Skip to content

Commit 492d24b

Browse files
author
Vasil Chimev
authored
Update Android SDK packages in macOS setup script (#2857)
1 parent 106a2e8 commit 492d24b

File tree

1 file changed

+11
-20
lines changed

1 file changed

+11
-20
lines changed

setup/native-script.rb

+11-20
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,7 @@ def install_environment_variable(name, value)
9797

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

132-
android_executable = File.join(ENV["ANDROID_HOME"], "tools", "bin", "sdkmanager")
133-
execute("echo y | #{android_executable} \"platform-tools\"", error_msg)
134-
execute("echo y | #{android_executable} \"tools\"", error_msg)
135-
execute("echo y | #{android_executable} \"build-tools;25.0.2\"", error_msg)
136-
execute("echo y | #{android_executable} \"platforms;android-25\"", error_msg)
137-
execute("echo y | #{android_executable} \"platforms;android-24\"", error_msg)
138-
execute("echo y | #{android_executable} \"platforms;android-23\"", error_msg)
139-
execute("echo y | #{android_executable} \"platforms;android-22\"", error_msg)
140-
execute("echo y | #{android_executable} \"platforms;android-21\"", error_msg)
141-
execute("echo y | #{android_executable} \"platforms;android-19\"", error_msg)
142-
execute("echo y | #{android_executable} \"platforms;android-18\"", error_msg)
143-
execute("echo y | #{android_executable} \"platforms;android-17\"", error_msg)
131+
sdk_manager = File.join(ENV["ANDROID_HOME"], "tools", "bin", "sdkmanager")
132+
execute("echo y | #{sdk_manager} \"platform-tools\"", error_msg)
133+
execute("echo y | #{sdk_manager} \"tools\"", error_msg)
134+
execute("echo y | #{sdk_manager} \"build-tools;25.0.2\"", error_msg)
135+
execute("echo y | #{sdk_manager} \"platforms;android-23\"", error_msg)
136+
execute("echo y | #{sdk_manager} \"extras;android;m2repository\"", error_msg)
137+
execute("echo y | #{sdk_manager} \"extras;google;m2repository\"", error_msg)
144138

145139
puts "Do you want to install Android emulator? (y/n)"
146140
if gets.chomp.downcase == "y"
147141
puts "Do you want to install HAXM (Hardware accelerated Android emulator)? (y/n)"
148142
if gets.chomp.downcase == "y"
149-
execute("echo y | #{android_executable} \"extras;intel;Hardware_Accelerated_Execution_Manager\"", error_msg)
150-
143+
execute("echo y | #{sdk_manager} \"extras;intel;Hardware_Accelerated_Execution_Manager\"", error_msg)
151144
haxm_silent_installer = File.join(ENV["ANDROID_HOME"], "extras", "intel", "Hardware_Accelerated_Execution_Manager", "silent_install.sh")
152145
execute("sudo #{haxm_silent_installer}", "There seem to be some problems with the Android configuration")
153-
else
154146
end
155-
execute("echo y | #{android_executable} \"system-images;android-25;google_apis;x86\"", error_msg)
156-
execute("echo y | #{android_executable} \"system-images;android-24;default;x86\"", error_msg)
147+
execute("echo y | #{sdk_manager} \"system-images;android-23;default;x86\"", error_msg)
157148
end
158149

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

0 commit comments

Comments
 (0)