-
-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathcommon-script.ps1
41 lines (34 loc) · 1.88 KB
/
common-script.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
function Create-AVD{
$androidExecutable = [io.path]::combine($env:ANDROID_HOME, "tools", "bin", "sdkmanager")
$avdManagerExecutable = [io.path]::combine($env:ANDROID_HOME, "tools", "bin", "avdmanager")
# Setup Default Emulator
$installEmulatorAnswer = ''
Do {
$installEmulatorAnswer = (Read-Host "Do you want to install Android emulator? (Y)es/(N)o").ToLower()
}
While ($installEmulatorAnswer -ne 'y' -and $installEmulatorAnswer -ne 'n')
if ($installEmulatorAnswer -eq 'y') {
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"
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) {
Write-Host -ForegroundColor Red "ERROR: An error occurred while installing Android emulator. Please, install it manually."
}else{
Write-Host -ForegroundColor Green "Android emulator is successfully installed."
}
}
}