Skip to content

Commit d67aba8

Browse files
author
PROGRESS\radeva
committed
fix: Test-Path param check + accept all licenses
1 parent dbea46c commit d67aba8

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

native-script.ps1

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,11 @@ Install "Google Chrome" "Installing Google Chrome (required to debug NativeScrip
7676

7777
Install "Java Development Kit" "Installing Java Development Kit" "choco upgrade jdk8 --force"
7878

79-
$androidHomePathExists = Test-Path $env:ANDROID_HOME
79+
$androidHomePathExists = $False
80+
if($env:ANDROID_HOME){
81+
$androidHomePathExists = Test-Path $env:ANDROID_HOME
82+
}
83+
8084
if($androidHomePathExists -eq $False){
8185
[Environment]::SetEnvironmentVariable("ANDROID_HOME",$null,"User")
8286
}
@@ -118,19 +122,28 @@ Write-Host -ForegroundColor DarkYellow "Setting up Android SDK..."
118122
$androidToolsPath = [io.path]::combine($env:ANDROID_HOME, "tools")
119123
$androidToolsOldPath = [io.path]::combine($env:ANDROID_HOME, "toolsOld")
120124

121-
$androidToolsPathExists = Test-Path $androidToolsPath
125+
$androidToolsPathExists = $False
126+
if($androidToolsPath){
127+
$androidToolsPathExists = Test-Path $androidToolsPath
128+
}
129+
122130
if($androidToolsPathExists -eq $True){
123131
Write-Host -ForegroundColor DarkYellow "Updating Android SDK tools..."
124132
Copy-Item "$androidToolsPath" "$androidToolsOldPath" -recurse
125-
echo y | cmd /c "%ANDROID_HOME%\toolsOld\bin\sdkmanager.bat" "tools"
133+
echo y | cmd /c "%ANDROID_HOME%\toolsOld\bin\sdkmanager.bat" "tools" --licenses
126134
Remove-Item "$androidToolsOldPath" -Force -Recurse
127135
} else {
128136
Write-Host -ForegroundColor Red "ERROR: Failed to update Android SDK tools. This is a blocker to install default emulator, so please update manually once this installation has finished."
129137
}
130138

131139
# add repositories.cfg if it is not created
132140
$repositoriesConfigPath = [io.path]::combine($env:USERPROFILE, ".android", "repositories.cfg")
133-
$pathExists = Test-Path $repositoriesConfigPath
141+
142+
$pathExists = $False
143+
if($repositoriesConfigPath){
144+
$pathExists = Test-Path $repositoriesConfigPath
145+
}
146+
134147
if($pathExists -eq $False){
135148
Write-Host -ForegroundColor DarkYellow "Creating file $repositoriesConfigPath ..."
136149
New-Item $repositoriesConfigPath -type file

0 commit comments

Comments
 (0)