@@ -71,16 +71,21 @@ Install "Google Chrome" "Installing Google Chrome (required to debug NativeScrip
71
71
Install " Java Development Kit" " Installing Java Development Kit" " cinst jdk8 --force --yes"
72
72
73
73
Install " 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
-
79
74
# setup environment
80
75
81
76
if (! $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" )
84
89
}
85
90
86
91
if (! $env: JAVA_HOME ) {
@@ -90,5 +95,16 @@ if (!$env:JAVA_HOME) {
90
95
$env: JAVA_HOME = $javaHome ;
91
96
}
92
97
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
+
93
109
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."
94
110
Pause
0 commit comments