@@ -61,12 +61,13 @@ class AndroidSDK {
6161 private final File folder ;
6262 private final File tools ;
6363 private final File platforms ;
64- private final File highestPlatform ;
64+ private final File highestPlatform ;
6565 private final File androidJar ;
6666 private final File platformTools ;
6767 private final File buildTools ;
6868 private final File avdManager ;
6969 private final File sdkManager ;
70+ private final File emulator ;
7071
7172 private static final String SDK_DOWNLOAD_URL =
7273 "https://developer.android.com/studio/index.html#downloads" ;
@@ -122,7 +123,6 @@ public AndroidSDK(File folder) throws BadSDKException, IOException {
122123 ArrayList <SDKTarget > targets = getAvailableSdkTargets ();
123124 int highest = 1 ;
124125 for (SDKTarget targ : targets ) {
125- System .out .println (targ );
126126 if (highest < targ .version ) {
127127 highest = targ .version ;
128128 }
@@ -143,7 +143,16 @@ public AndroidSDK(File folder) throws BadSDKException, IOException {
143143
144144 avdManager = findCliTool (new File (tools , "bin" ), "avdmanager" );
145145 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+
147156 String path = Platform .getenv ("PATH" );
148157
149158 Platform .setenv ("ANDROID_SDK" , folder .getCanonicalPath ());
@@ -214,28 +223,9 @@ protected void checkDebugCertificate() {
214223 }
215224
216225
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 () {
228227 return folder ;
229228 }
230-
231-
232- public File getHighestPlatform () {
233- return highestPlatform ;
234- }
235-
236- public File getAndroidJarPath () {
237- return androidJar ;
238- }
239229
240230
241231 public File getBuildToolsFolder () {
@@ -246,17 +236,32 @@ public File getBuildToolsFolder() {
246236 public File getPlatformToolsFolder () {
247237 return platformTools ;
248238 }
249-
250239
251- // public File getWearableFolder() {
252- // return wearablePath;
253- // }
254240
241+ public File getAndroidJarPath () {
242+ return androidJar ;
243+ }
244+
245+
246+ public File getToolsFolder () {
247+ return tools ;
248+ }
255249
256- // public File getSupportLibrary() {
257- // return supportLibPath;
258- // }
259250
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+
260265
261266 public File getZipAlignTool () {
262267 File [] files = buildTools .listFiles ();
@@ -276,8 +281,7 @@ public File getZipAlignTool() {
276281 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 " ;
277282
278283 private void acceptLicenses () {
279- ProcessBuilder pb = new ProcessBuilder (sdkManager .getAbsolutePath (),
280- "--licenses" );
284+ ProcessBuilder pb = new ProcessBuilder (sdkManager .getAbsolutePath (), "--licenses" );
281285 pb .redirectErrorStream (true );
282286 try {
283287 Process process = pb .start ();
@@ -324,14 +328,17 @@ static public File getGoogleDriverFolder() {
324328
325329 /**
326330 * 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
328332 * so that it can be called explicitly.
329333 */
330334 private static File findCliTool (final File tools , String name )
331335 throws BadSDKException {
332336 if (new File (tools , name + ".bat" ).exists ()) {
333337 return new File (tools , name + ".bat" );
334338 }
339+ if (new File (tools , name + ".exe" ).exists ()) {
340+ return new File (tools , name + ".exe" );
341+ }
335342 if (new File (tools , name ).exists ()) {
336343 return new File (tools , name );
337344 }
0 commit comments