@@ -135,22 +135,7 @@ tasks.whenTaskAdded { packageTask ->
135
135
}
136
136
137
137
task run (type : Exec ) {
138
- def path
139
- def localProperties = project. file(" ../local.properties" )
140
- if (localProperties. exists()) {
141
- Properties properties = new Properties ()
142
- localProperties. withInputStream { instr ->
143
- properties. load(instr)
144
- }
145
- def sdkDir = properties. getProperty(' sdk.dir' )
146
- if (sdkDir) {
147
- path = sdkDir
148
- } else {
149
- path = " $System . env . ANDROID_HOME "
150
- }
151
- } else {
152
- path = " $System . env . ANDROID_HOME "
153
- }
138
+ def path = getSdkFolder()
154
139
155
140
def adb = path + " /platform-tools/adb"
156
141
commandLine " $adb " , ' shell' , ' am' , ' start' , ' -n' , android. defaultConfig. applicationId + ' /' + ' com.bladecoder.engine.AndroidLauncher'
@@ -179,9 +164,30 @@ tasks.whenTaskAdded { task ->
179
164
}
180
165
}
181
166
167
+ String getSdkFolder () {
168
+ def path
169
+ def localProperties = project. file(" ../local.properties" )
170
+ if (localProperties. exists()) {
171
+ Properties properties = new Properties ()
172
+ localProperties. withInputStream { instr ->
173
+ properties. load(instr)
174
+ }
175
+ def sdkDir = properties. getProperty(' sdk.dir' )
176
+ if (sdkDir) {
177
+ path = sdkDir
178
+ } else {
179
+ path = " $System . env . ANDROID_HOME "
180
+ }
181
+ } else {
182
+ path = " $System . env . ANDROID_HOME "
183
+ }
184
+
185
+ return path
186
+ }
187
+
182
188
String highestSdkAvailable (String defaultSdk ) {
183
189
try {
184
- def buildToolsDir = new File (android . getSdkDirectory() . toString (), " platforms" )
190
+ def buildToolsDir = new File (getSdkFolder (), " platforms" )
185
191
def sdks = buildToolsDir. list([accept :{ d , f -> f. startsWith(" android-" ) && new File (d, f). isDirectory() }] as FilenameFilter ). sort { a , b -> b <=> a }
186
192
def highestSdk = sdks[0 ]
187
193
if (highestSdk != null ) {
@@ -198,3 +204,4 @@ String highestSdkAvailable(String defaultSdk) {
198
204
defaultSdk
199
205
}
200
206
}
207
+
0 commit comments