Skip to content

chore: update to Android SDK 28 #17

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 2 commits into from
Nov 2, 2018
Merged
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
45 changes: 16 additions & 29 deletions common-script.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -10,39 +10,26 @@ function Create-AVD{
While ($installEmulatorAnswer -ne 'y' -and $installEmulatorAnswer -ne 'n')

if ($installEmulatorAnswer -eq 'y') {
if ((Read-Host "Do you want to install HAXM (Hardware accelerated Android emulator)?") -eq 'y') {
Write-Host -ForegroundColor DarkYellow "Setting up Android SDK system-images;android-25;google_apis;x86..."
echo y | cmd /c "$androidExecutable" "system-images;android-25;google_apis;x86"
Write-Host -ForegroundColor DarkYellow "Setting up Android SDK system-images;android-28;google_apis;x86..."
echo y | cmd /c "$androidExecutable" "system-images;android-28;google_apis;x86"

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" "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"

if ($LASTEXITCODE -ne 0) {
Write-Host -ForegroundColor Yellow "WARNING: Failed to install HAXM in silent mode. Starting interactive mode."
$haxmInstaller = [io.path]::combine($env:ANDROID_HOME, "extras", "intel", "Hardware_Accelerated_Execution_Manager", "intelhaxm-android.exe")
cmd /c "$haxmInstaller"
}

$cmdArgList = @(
"create",
"avd",
"-n","Emulator-Api25-Default-haxm",
"-k",'"system-images;android-25;google_apis;x86"'
)
}
else {
Write-Host "Setting up Android SDK system-images;android-25;google_apis;armeabi-v7a..."
echo y | cmd /c "$androidExecutable" "system-images;android-25;google_apis;armeabi-v7a"

$cmdArgList = @(
"create",
"avd",
"-n","Emulator-Api25-Default",
"-k",'"system-images;android-25;google_apis;armeabi-v7a"'
)
if ($LASTEXITCODE -ne 0) {
Write-Host -ForegroundColor Yellow "WARNING: Failed to install HAXM in silent mode. Starting interactive mode."
$haxmInstaller = [io.path]::combine($env:ANDROID_HOME, "extras", "intel", "Hardware_Accelerated_Execution_Manager", "intelhaxm-android.exe")
cmd /c "$haxmInstaller"
}

$cmdArgList = @(
"create",
"avd",
"-n","Emulator-Api28-Default",
"-k",'"system-images;android-28;google_apis;x86"'
)

echo no | cmd /c $avdManagerExecutable $cmdArgList

if ($LASTEXITCODE -ne 0) {
Expand Down
8 changes: 4 additions & 4 deletions native-script.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,10 @@ $androidExecutable = [io.path]::combine($env:ANDROID_HOME, "tools", "bin", "sdkm

Write-Host -ForegroundColor DarkYellow "Setting up Android SDK platform-tools..."
echo y | cmd /c "$androidExecutable" "platform-tools"
Write-Host -ForegroundColor DarkYellow "Setting up Android SDK build-tools;27.0.3..."
echo y | cmd /c "$androidExecutable" "build-tools;27.0.3"
Write-Host -ForegroundColor DarkYellow "Setting up Android SDK platforms;android-25..."
echo y | cmd /c "$androidExecutable" "platforms;android-25"
Write-Host -ForegroundColor DarkYellow "Setting up Android SDK build-tools;28.0.3..."
echo y | cmd /c "$androidExecutable" "build-tools;28.0.3"
Write-Host -ForegroundColor DarkYellow "Setting up Android SDK platforms;android-28..."
echo y | cmd /c "$androidExecutable" "platforms;android-28"
Write-Host -ForegroundColor DarkYellow "Setting up Android SDK extras;android;m2repository..."
echo y | cmd /c "$androidExecutable" "extras;android;m2repository"
Write-Host -ForegroundColor DarkYellow "Setting up Android SDK extras;google;m2repository..."
Expand Down
36 changes: 22 additions & 14 deletions native-script.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,18 @@ def install_environment_variable(name, value)
# Allow brew to lookup versions
execute("brew tap caskroom/versions", "", false)

# Install Google Chrome
install("Google Chrome", "Installing Google Chrome (required to debug NativeScript apps)", "brew cask install google-chrome", false, false);

# Install JDK 1.8
install("Java SE Development Kit 8", "Installing the Java SE Development Kit 8 ... This might take some time, please, be patient. (You will be prompted for your password)", 'brew cask install java8', false, false)
install("Android SDK", "Installing Android SDK", 'brew tap caskroom/cask; brew cask install android-sdk', false)
unless ENV["JAVA_HOME"]
puts "Set JAVA_HOME=$(/usr/libexec/java_home -v 1.8)"
install_environment_variable("JAVA_HOME", "$(/usr/libexec/java_home -v 1.8)")
end

# Install Android SDK
install("Android SDK", "Installing Android SDK", 'brew tap caskroom/cask; brew cask install android-sdk', false)
unless ENV["ANDROID_HOME"]
require 'pathname'
android_home = "/usr/local/share/android-sdk"
Expand All @@ -121,14 +129,9 @@ def install_environment_variable(name, value)
android_home = Pathname.new(android_home_joined_path).realpath
end
end

install_environment_variable("ANDROID_HOME", android_home)
end

unless ENV["JAVA_HOME"]
install_environment_variable("JAVA_HOME", "/Library/Java/Home")
end

# the -p flag is set in order to ensure zero status code even if the directory exists
execute("mkdir -p ~/.cocoapods", "There was a problem in creating ~/.cocoapods directory")
# CocoaPods already has a dependency to xcodeproj and also has a dependency to a lower version of activesupport
Expand All @@ -148,23 +151,28 @@ def install_environment_variable(name, value)
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;27.0.3\"", error_msg)
execute("echo y | #{sdk_manager} \"platforms;android-25\"", error_msg)
execute("echo y | #{sdk_manager} \"build-tools;28.0.3\"", error_msg)
execute("echo y | #{sdk_manager} \"platforms;android-28\"", 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)"
puts "Do you want to install Android emulator system image? (y/n)"
if $silentMode || gets.chomp.downcase == "y"
puts "Do you want to install HAXM (Hardware accelerated Android emulator)? (y/n)"
if $silentMode || gets.chomp.downcase == "y"
execute("echo y | #{sdk_manager} \"extras;intel;Hardware_Accelerated_Execution_Manager\"", error_msg)
execute("echo y | #{sdk_manager} \"extras;intel;Hardware_Accelerated_Execution_Manager\"", "Failed to download Intel HAXM.")
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")
execute("echo y | #{sdk_manager} \"system-images;android-25;default;x86\"", error_msg)
else
execute("echo y | #{sdk_manager} \"system-images;android-25;google_apis;armeabi-v7a\"", error_msg)
execute("sudo #{haxm_silent_installer}", "Failed to install Intel HAXM.")
execute("echo y | #{sdk_manager} \"system-images;android-28;google_apis;x86\"", "Failed to download Android emulator system image.")
end
end

puts "Do you want to create Android emulator? (y/n)"
if $silentMode || gets.chomp.downcase == "y"
error_msg = "Failed to create Android emulator."
avd_manager = File.join(ENV["ANDROID_HOME"], "tools", "bin", "avdmanager")
execute("echo y | #{avdmanager} create avd -n Emulator-Api28-Google -k \"system-images;android-28;google_apis;x86\" -b google_apis/x86 -c 265M -f", 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."