@@ -61,12 +61,13 @@ class AndroidSDK {
61
61
private final File folder ;
62
62
private final File tools ;
63
63
private final File platforms ;
64
- private final File highestPlatform ;
64
+ private final File highestPlatform ;
65
65
private final File androidJar ;
66
66
private final File platformTools ;
67
67
private final File buildTools ;
68
68
private final File avdManager ;
69
69
private final File sdkManager ;
70
+ private final File emulator ;
70
71
71
72
private static final String SDK_DOWNLOAD_URL =
72
73
"https://developer.android.com/studio/index.html#downloads" ;
@@ -122,7 +123,6 @@ public AndroidSDK(File folder) throws BadSDKException, IOException {
122
123
ArrayList <SDKTarget > targets = getAvailableSdkTargets ();
123
124
int highest = 1 ;
124
125
for (SDKTarget targ : targets ) {
125
- System .out .println (targ );
126
126
if (highest < targ .version ) {
127
127
highest = targ .version ;
128
128
}
@@ -143,7 +143,16 @@ public AndroidSDK(File folder) throws BadSDKException, IOException {
143
143
144
144
avdManager = findCliTool (new File (tools , "bin" ), "avdmanager" );
145
145
sdkManager = findCliTool (new File (tools , "bin" ), "sdkmanager" );
146
-
146
+
147
+ File emuFolder = new File (folder , "emulator" );
148
+ if (emuFolder .exists ()) {
149
+ // First try the new location of the emulator inside its own folder
150
+ emulator = findCliTool (emuFolder , "emulator" );
151
+ } else {
152
+ // If not found, use old location inside tools
153
+ emulator = findCliTool (tools , "emulator" );
154
+ }
155
+
147
156
String path = Platform .getenv ("PATH" );
148
157
149
158
Platform .setenv ("ANDROID_SDK" , folder .getCanonicalPath ());
@@ -214,28 +223,9 @@ protected void checkDebugCertificate() {
214
223
}
215
224
216
225
217
- public File getToolsFolder () {
218
- return tools ;
219
- }
220
-
221
-
222
- public String getAvdManagerPath () {
223
- return avdManager .getAbsolutePath ();
224
- }
225
-
226
-
227
- public File getSdkFolder () {
226
+ public File getFolder () {
228
227
return folder ;
229
228
}
230
-
231
-
232
- public File getHighestPlatform () {
233
- return highestPlatform ;
234
- }
235
-
236
- public File getAndroidJarPath () {
237
- return androidJar ;
238
- }
239
229
240
230
241
231
public File getBuildToolsFolder () {
@@ -246,17 +236,32 @@ public File getBuildToolsFolder() {
246
236
public File getPlatformToolsFolder () {
247
237
return platformTools ;
248
238
}
249
-
250
239
251
- // public File getWearableFolder() {
252
- // return wearablePath;
253
- // }
254
240
241
+ public File getAndroidJarPath () {
242
+ return androidJar ;
243
+ }
244
+
245
+
246
+ public File getToolsFolder () {
247
+ return tools ;
248
+ }
255
249
256
- // public File getSupportLibrary() {
257
- // return supportLibPath;
258
- // }
259
250
251
+ public File getEmulatorTool () {
252
+ return emulator ;
253
+ }
254
+
255
+
256
+ public File getAVDManagerTool () {
257
+ return avdManager ;
258
+ }
259
+
260
+
261
+ public File getHighestPlatform () {
262
+ return highestPlatform ;
263
+ }
264
+
260
265
261
266
public File getZipAlignTool () {
262
267
File [] files = buildTools .listFiles ();
@@ -276,8 +281,7 @@ public File getZipAlignTool() {
276
281
private static final String response = "y\n y\n y\n y\n y\n y\n y\n y\n y\n y\n " ;
277
282
278
283
private void acceptLicenses () {
279
- ProcessBuilder pb = new ProcessBuilder (sdkManager .getAbsolutePath (),
280
- "--licenses" );
284
+ ProcessBuilder pb = new ProcessBuilder (sdkManager .getAbsolutePath (), "--licenses" );
281
285
pb .redirectErrorStream (true );
282
286
try {
283
287
Process process = pb .start ();
@@ -324,14 +328,17 @@ static public File getGoogleDriverFolder() {
324
328
325
329
/**
326
330
* Checks a path to see if there's a tools/android file inside, a rough check
327
- * for the SDK installation. Also figures out the name of android/android.bat
331
+ * for the SDK installation. Also figures out the name of android/android.bat/android.exe
328
332
* so that it can be called explicitly.
329
333
*/
330
334
private static File findCliTool (final File tools , String name )
331
335
throws BadSDKException {
332
336
if (new File (tools , name + ".bat" ).exists ()) {
333
337
return new File (tools , name + ".bat" );
334
338
}
339
+ if (new File (tools , name + ".exe" ).exists ()) {
340
+ return new File (tools , name + ".exe" );
341
+ }
335
342
if (new File (tools , name ).exists ()) {
336
343
return new File (tools , name );
337
344
}
0 commit comments