Skip to content

[Do not merge] Update Android SDK Packages in setup scripts #2828

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
25 changes: 9 additions & 16 deletions setup/native-script.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -97,28 +97,21 @@ if (!$env:JAVA_HOME) {

# setup android sdk
# following commands are separated in case of having to answer to license agreements
# the android tool will introduce a --accept-license option in subsequent releases
$androidExecutable = [io.path]::combine($env:ANDROID_HOME, "tools", "android")
echo y | cmd /c "$androidExecutable" update sdk --filter "platform-tools" --all --no-ui
echo y | cmd /c "$androidExecutable" update sdk --filter "tools" --all --no-ui
echo y | cmd /c "$androidExecutable" update sdk --filter "android-23" --all --no-ui
echo y | cmd /c "$androidExecutable" update sdk --filter "build-tools-25.0.2" --all --no-ui
echo y | cmd /c "$androidExecutable" update sdk --filter "build-tools-23.0.3" --all --no-ui
echo y | cmd /c "$androidExecutable" update sdk --filter "extra-android-m2repository" --all --no-ui
$androidExecutable = [io.path]::combine($env:ANDROID_HOME, "tools", "bin", "sdkmanager")
echo y | cmd /c "$androidExecutable" "platform-tools"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unable to test, perhaps it should be escaped.

echo y | cmd /c "$androidExecutable" "tools"
echo y | cmd /c "$androidExecutable" "build-tools;25.0.2"
echo y | cmd /c "$androidExecutable" "platforms;android-23"
echo y | cmd /c "$androidExecutable" "extras;android;m2repository"
echo y | cmd /c "$androidExecutable" "extras;google;m2repository"

if ((Read-Host "Do you want to install Android emulator?") -eq 'y') {
if ((Read-Host "Do you want to install HAXM (Hardware accelerated Android emulator)?") -eq 'y') {
echo y | cmd /c "$androidExecutable" update sdk --filter extra-intel-Hardware_Accelerated_Execution_Manager --all --no-ui

echo y | cmd /c "$androidExecutable" "extras;intel;Hardware_Accelerated_Execution_Manager"
$haxmSilentInstaller = [io.path]::combine($env:ANDROID_HOME, "extras", "intel", "Hardware_Accelerated_Execution_Manager", "silent_install.bat")
cmd /c "$haxmSilentInstaller"

echo y | cmd /c "$androidExecutable" update sdk --filter sys-img-x86-android-23 --all --no-ui
echo no | cmd /c "$androidExecutable" create avd -n Emulator-Api23-Default -t android-23 --abi default/x86 -c 12M -f
} else {
echo y | cmd /c "$androidExecutable" update sdk --filter sys-img-armeabi-v7a-android-23 --all --no-ui
echo no | cmd /c "$androidExecutable" create avd -n Emulator-Api23-Default -t android-23 --abi default/armeabi-v7a -c 12M -f
}
echo y | cmd /c "$androidExecutable" "system-images;android-25;google_apis;x86"
Copy link
Author

@vchimev vchimev May 22, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's both scripts for macOS and Windows do the same.
To consider:

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we install android-23 images?
Reason:

  • It is the most used version
  • Boots faster

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in #2857.

}

Write-Host -ForegroundColor Green "This script has modified your environment. You need to log off and log back on for the changes to take effect."
Expand Down
17 changes: 4 additions & 13 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 @@ -134,26 +133,18 @@ def install_environment_variable(name, value)
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)
execute("echo y | #{android_executable} \"extras;android;m2repository\"", error_msg)
execute("echo y | #{android_executable} \"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)

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 | #{android_executable} \"system-images;android-25;google_apis;x86\"", error_msg)
end

puts "The ANDROID_HOME and JAVA_HOME environment variables have been added to your .bash_profile/.zprofile"
Expand Down