@@ -71,16 +71,21 @@ Install "Google Chrome" "Installing Google Chrome (required to debug NativeScrip
7171Install " Java Development Kit" " Installing Java Development Kit" " cinst jdk8 --force --yes"
7272
7373Install " Android SDK" " Installing Android SDK" " cinst android-sdk --force --yes"
74-
75- # setup android sdk
76- echo yes | cmd / c " $env: localappdata \Android\android-sdk\tools\android" update sdk -- filter " tools,platform-tools,android-23" -- all -- no- ui
77- echo yes | cmd / c " $env: localappdata \Android\android-sdk\tools\android" update sdk -- filter " build-tools-23.0.1,extra-android-m2repository" -- all -- no- ui
78-
7974# setup environment
8075
8176if (! $env: ANDROID_HOME ) {
82- [Environment ]::SetEnvironmentVariable(" ANDROID_HOME" , " $env: localappdata \Android\android-sdk" , " User" )
83- $env: ANDROID_HOME = " $env: localappdata \Android\android-sdk" ;
77+ # in case the user has `android` in the PATH, use it as base for setting ANDROID_HOME
78+ $androidExecutableEnvironmentPath = Get-Command android - ErrorAction SilentlyContinue | Select-Object - ExpandProperty Definition
79+ if ($androidExecutableEnvironmentPath -ne $null ) {
80+ $androidHomeJoinedPath = [io.path ]::combine($androidExecutableEnvironmentPath , " .." , " .." )
81+ $androidHome = Resolve-Path $androidHomeJoinedPath | Select-Object - ExpandProperty Path
82+ }
83+ else {
84+ $androidHome = " $env: localappdata \Android\android-sdk"
85+ }
86+
87+ $env: ANDROID_HOME = $androidHome ;
88+ [Environment ]::SetEnvironmentVariable(" ANDROID_HOME" , " $env: ANDROID_HOME " , " User" )
8489}
8590
8691if (! $env: JAVA_HOME ) {
@@ -90,5 +95,16 @@ if (!$env:JAVA_HOME) {
9095 $env: JAVA_HOME = $javaHome ;
9196}
9297
98+ # setup android sdk
99+ # following commands are separated in case of having to answer to license agreements
100+ # the android tool will introduce a --accept-license option in subsequent releases
101+ $androidExecutable = [io.path ]::combine($env: ANDROID_HOME , " tools" , " android" )
102+ echo y | cmd / c " $androidExecutable " update sdk -- filter " tools" -- all -- no- ui
103+ echo y | cmd / c " $androidExecutable " update sdk -- filter " platform-tools" -- all -- no- ui
104+ echo y | cmd / c " $androidExecutable " update sdk -- filter " android-23" -- all -- no- ui
105+ echo y | cmd / c " $androidExecutable " update sdk -- filter " build-tools-23.0.2" -- all -- no- ui
106+ echo y | cmd / c " $androidExecutable " update sdk -- filter " extra-android-m2repository" -- all -- no- ui
107+
108+
93109Write-Host - ForegroundColor Green " This script has modified your environment. You need to log off and log back on for the changes to take effect."
94110Pause
0 commit comments