Skip to content

Commit 7f3cd58

Browse files
authored
Merge pull request #17 from NativeScript/dtopuzov/update-to-sdk28
chore: update to Android SDK 28
2 parents 4d7e8a9 + 81baabe commit 7f3cd58

File tree

3 files changed

+42
-47
lines changed

3 files changed

+42
-47
lines changed

common-script.ps1

+16-29
Original file line numberDiff line numberDiff line change
@@ -10,39 +10,26 @@ function Create-AVD{
1010
While ($installEmulatorAnswer -ne 'y' -and $installEmulatorAnswer -ne 'n')
1111

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

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

21-
if ($LASTEXITCODE -ne 0) {
22-
Write-Host -ForegroundColor Yellow "WARNING: Failed to install HAXM in silent mode. Starting interactive mode."
23-
$haxmInstaller = [io.path]::combine($env:ANDROID_HOME, "extras", "intel", "Hardware_Accelerated_Execution_Manager", "intelhaxm-android.exe")
24-
cmd /c "$haxmInstaller"
25-
}
26-
27-
$cmdArgList = @(
28-
"create",
29-
"avd",
30-
"-n","Emulator-Api25-Default-haxm",
31-
"-k",'"system-images;android-25;google_apis;x86"'
32-
)
33-
}
34-
else {
35-
Write-Host "Setting up Android SDK system-images;android-25;google_apis;armeabi-v7a..."
36-
echo y | cmd /c "$androidExecutable" "system-images;android-25;google_apis;armeabi-v7a"
37-
38-
$cmdArgList = @(
39-
"create",
40-
"avd",
41-
"-n","Emulator-Api25-Default",
42-
"-k",'"system-images;android-25;google_apis;armeabi-v7a"'
43-
)
20+
if ($LASTEXITCODE -ne 0) {
21+
Write-Host -ForegroundColor Yellow "WARNING: Failed to install HAXM in silent mode. Starting interactive mode."
22+
$haxmInstaller = [io.path]::combine($env:ANDROID_HOME, "extras", "intel", "Hardware_Accelerated_Execution_Manager", "intelhaxm-android.exe")
23+
cmd /c "$haxmInstaller"
4424
}
4525

26+
$cmdArgList = @(
27+
"create",
28+
"avd",
29+
"-n","Emulator-Api28-Default",
30+
"-k",'"system-images;android-28;google_apis;x86"'
31+
)
32+
4633
echo no | cmd /c $avdManagerExecutable $cmdArgList
4734

4835
if ($LASTEXITCODE -ne 0) {

native-script.ps1

+4-4
Original file line numberDiff line numberDiff line change
@@ -156,10 +156,10 @@ $androidExecutable = [io.path]::combine($env:ANDROID_HOME, "tools", "bin", "sdkm
156156

157157
Write-Host -ForegroundColor DarkYellow "Setting up Android SDK platform-tools..."
158158
echo y | cmd /c "$androidExecutable" "platform-tools"
159-
Write-Host -ForegroundColor DarkYellow "Setting up Android SDK build-tools;27.0.3..."
160-
echo y | cmd /c "$androidExecutable" "build-tools;27.0.3"
161-
Write-Host -ForegroundColor DarkYellow "Setting up Android SDK platforms;android-25..."
162-
echo y | cmd /c "$androidExecutable" "platforms;android-25"
159+
Write-Host -ForegroundColor DarkYellow "Setting up Android SDK build-tools;28.0.3..."
160+
echo y | cmd /c "$androidExecutable" "build-tools;28.0.3"
161+
Write-Host -ForegroundColor DarkYellow "Setting up Android SDK platforms;android-28..."
162+
echo y | cmd /c "$androidExecutable" "platforms;android-28"
163163
Write-Host -ForegroundColor DarkYellow "Setting up Android SDK extras;android;m2repository..."
164164
echo y | cmd /c "$androidExecutable" "extras;android;m2repository"
165165
Write-Host -ForegroundColor DarkYellow "Setting up Android SDK extras;google;m2repository..."

native-script.rb

+22-14
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,18 @@ def install_environment_variable(name, value)
105105
# Allow brew to lookup versions
106106
execute("brew tap caskroom/versions", "", false)
107107

108+
# Install Google Chrome
108109
install("Google Chrome", "Installing Google Chrome (required to debug NativeScript apps)", "brew cask install google-chrome", false, false);
110+
111+
# Install JDK 1.8
109112
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)
110-
install("Android SDK", "Installing Android SDK", 'brew tap caskroom/cask; brew cask install android-sdk', false)
113+
unless ENV["JAVA_HOME"]
114+
puts "Set JAVA_HOME=$(/usr/libexec/java_home -v 1.8)"
115+
install_environment_variable("JAVA_HOME", "$(/usr/libexec/java_home -v 1.8)")
116+
end
111117

118+
# Install Android SDK
119+
install("Android SDK", "Installing Android SDK", 'brew tap caskroom/cask; brew cask install android-sdk', false)
112120
unless ENV["ANDROID_HOME"]
113121
require 'pathname'
114122
android_home = "/usr/local/share/android-sdk"
@@ -121,14 +129,9 @@ def install_environment_variable(name, value)
121129
android_home = Pathname.new(android_home_joined_path).realpath
122130
end
123131
end
124-
125132
install_environment_variable("ANDROID_HOME", android_home)
126133
end
127134

128-
unless ENV["JAVA_HOME"]
129-
install_environment_variable("JAVA_HOME", "/Library/Java/Home")
130-
end
131-
132135
# the -p flag is set in order to ensure zero status code even if the directory exists
133136
execute("mkdir -p ~/.cocoapods", "There was a problem in creating ~/.cocoapods directory")
134137
# CocoaPods already has a dependency to xcodeproj and also has a dependency to a lower version of activesupport
@@ -148,23 +151,28 @@ def install_environment_variable(name, value)
148151
sdk_manager = File.join(ENV["ANDROID_HOME"], "tools", "bin", "sdkmanager")
149152
execute("echo y | #{sdk_manager} \"platform-tools\"", error_msg)
150153
execute("echo y | #{sdk_manager} \"tools\"", error_msg)
151-
execute("echo y | #{sdk_manager} \"build-tools;27.0.3\"", error_msg)
152-
execute("echo y | #{sdk_manager} \"platforms;android-25\"", error_msg)
154+
execute("echo y | #{sdk_manager} \"build-tools;28.0.3\"", error_msg)
155+
execute("echo y | #{sdk_manager} \"platforms;android-28\"", error_msg)
153156
execute("echo y | #{sdk_manager} \"extras;android;m2repository\"", error_msg)
154157
execute("echo y | #{sdk_manager} \"extras;google;m2repository\"", error_msg)
155158

156-
puts "Do you want to install Android emulator? (y/n)"
159+
puts "Do you want to install Android emulator system image? (y/n)"
157160
if $silentMode || gets.chomp.downcase == "y"
158161
puts "Do you want to install HAXM (Hardware accelerated Android emulator)? (y/n)"
159162
if $silentMode || gets.chomp.downcase == "y"
160-
execute("echo y | #{sdk_manager} \"extras;intel;Hardware_Accelerated_Execution_Manager\"", error_msg)
163+
execute("echo y | #{sdk_manager} \"extras;intel;Hardware_Accelerated_Execution_Manager\"", "Failed to download Intel HAXM.")
161164
haxm_silent_installer = File.join(ENV["ANDROID_HOME"], "extras", "intel", "Hardware_Accelerated_Execution_Manager", "silent_install.sh")
162-
execute("sudo #{haxm_silent_installer}", "There seem to be some problems with the Android configuration")
163-
execute("echo y | #{sdk_manager} \"system-images;android-25;default;x86\"", error_msg)
164-
else
165-
execute("echo y | #{sdk_manager} \"system-images;android-25;google_apis;armeabi-v7a\"", error_msg)
165+
execute("sudo #{haxm_silent_installer}", "Failed to install Intel HAXM.")
166+
execute("echo y | #{sdk_manager} \"system-images;android-28;google_apis;x86\"", "Failed to download Android emulator system image.")
166167
end
167168
end
168169

170+
puts "Do you want to create Android emulator? (y/n)"
171+
if $silentMode || gets.chomp.downcase == "y"
172+
error_msg = "Failed to create Android emulator."
173+
avd_manager = File.join(ENV["ANDROID_HOME"], "tools", "bin", "avdmanager")
174+
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)
175+
end
176+
169177
puts "The ANDROID_HOME and JAVA_HOME environment variables have been added to your .bash_profile/.zprofile"
170178
puts "Restart the terminal or run `source ~/.bash_profile` to use them."

0 commit comments

Comments
 (0)