Skip to content

Commit 3802c53

Browse files
author
Vladimir Enchev
committed
Create Android default emulator
1 parent 6cba2ba commit 3802c53

File tree

2 files changed

+38
-5
lines changed

2 files changed

+38
-5
lines changed

setup/native-script.ps1

+14
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,20 @@ echo y | cmd /c "$androidExecutable" update sdk --filter "android-23" --all --no
105105
echo y | cmd /c "$androidExecutable" update sdk --filter "build-tools-23.0.2" --all --no-ui
106106
echo y | cmd /c "$androidExecutable" update sdk --filter "extra-android-m2repository" --all --no-ui
107107

108+
if ((Read-Host "Do you want to install Android emulator?") -eq 'y') {
109+
if ((Read-Host "Do you want to install HAXM (Hardware accelerated Android emulator)?") -eq 'y') {
110+
echo y | $ANDROID_HOME/tools/android update sdk --filter extra-intel-Hardware_Accelerated_Execution_Manager --all --no-ui
111+
112+
$haxmSilentInstaller = [io.path]::combine($env:ANDROID_HOME, "extras", "intel", "Hardware_Accelerated_Execution_Manager", "silent_install.bat")
113+
cmd /c "$haxmSilentInstaller"
114+
115+
echo y | $ANDROID_HOME/tools/android update sdk --filter sys-img-x86-android-23 --all --no-ui
116+
echo no | $ANDROID_HOME/tools/android create avd -n Emulator-Api23-Default -t android-23 --abi default/x86 -c 12M -f
117+
} else {
118+
echo y | $ANDROID_HOME/tools/android update sdk --filter sys-img-armeabi-v7a-android-23 --all --no-ui
119+
echo no | $ANDROID_HOME/tools/android create avd -n Emulator-Api23-Default -t android-23 --abi default/armeabi-v7a -c 12M -f
120+
}
121+
}
108122

109123
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."
110124
Pause

setup/native-script.rb

+24-5
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,30 @@ def install(program_name, message, script, run_as_root = false, show_all_option
114114
puts "Configuring your system for Android development... This might take some time, please, be patient."
115115
# Note that multiple license acceptances may be required, hence the multiple commands
116116
# the android tool will introduce a --accept-license option in subsequent releases
117+
error_msg = "There seem to be some problems with the Android configuration"
118+
117119
android_executable = File.join(ENV["ANDROID_HOME"], "tools", "android")
118-
execute("echo y | #{android_executable} update sdk --filter platform-tools --all --no-ui", "There seem to be some problems with the Android configuration")
119-
execute("echo y | #{android_executable} update sdk --filter tools --all --no-ui", "There seem to be some problems with the Android configuration")
120-
execute("echo y | #{android_executable} update sdk --filter android-23 --all --no-ui", "There seem to be some problems with the Android configuration")
121-
execute("echo y | #{android_executable} update sdk --filter build-tools-23.0.2 --all --no-ui", "There seem to be some problems with the Android configuration")
122-
execute("echo y | #{android_executable} update sdk --filter extra-android-m2repository --all --no-ui", "There seem to be some problems with the Android configuration")
120+
execute("echo y | #{android_executable} update sdk --filter platform-tools --all --no-ui", "#{error_msg}"")
121+
execute("echo y | #{android_executable} update sdk --filter tools --all --no-ui", "#{error_msg}")
122+
execute("echo y | #{android_executable} update sdk --filter android-23 --all --no-ui", "#{error_msg}")
123+
execute("echo y | #{android_executable} update sdk --filter build-tools-23.0.2 --all --no-ui", "#{error_msg}")
124+
execute("echo y | #{android_executable} update sdk --filter extra-android-m2repository --all --no-ui", "#{error_msg}")
125+
126+
puts "Do you want to install Android emulator? (y/n)"
127+
if gets.chomp.downcase == "y"
128+
puts "Do you want to install HAXM (Hardware accelerated Android emulator)? (y/n)"
129+
if gets.chomp.downcase == "y"
130+
execute("echo y | $ANDROID_HOME/tools/android update sdk --filter extra-intel-Hardware_Accelerated_Execution_Manager --all --no-ui", "#{error_msg}")
131+
132+
haxm_silent_installer = File.join(ENV["ANDROID_HOME"], "extras", "intel", "Hardware_Accelerated_Execution_Manager", "silent_install.sh")
133+
execute("#{haxm_silent_installer}", "There seem to be some problems with the Android configuration")
134+
135+
execute("echo y | $ANDROID_HOME/tools/android update sdk --filter sys-img-x86-android-23 --all --no-ui", "#{error_msg}")
136+
execute("echo no | $ANDROID_HOME/tools/android create avd -n Emulator-Api23-Default -t android-23 --abi default/x86 -c 12M -f", "#{error_msg}")
137+
else
138+
execute("echo y | $ANDROID_HOME/tools/android update sdk --filter sys-img-armeabi-v7a-android-23 --all --no-ui", "#{error_msg}")
139+
execute("echo no | $ANDROID_HOME/tools/android create avd -n Emulator-Api23-Default -t android-23 --abi default/armeabi-v7a -c 12M -f", "#{error_msg}")
140+
end
141+
end
123142

124143
puts "The ANDROID_HOME and JAVA_HOME environment variables have been added to your .profile. Restart the terminal to use them."

0 commit comments

Comments
 (0)