@@ -79,8 +79,8 @@ public class SDKDownloader extends JDialog implements PropertyChangeListener {
79
79
80
80
class SDKUrlHolder {
81
81
public String platformVersion , buildToolsVersion ;
82
- public String platformToolsUrl , buildToolsUrl , platformUrl , toolsUrl , emulatorUrl ;
83
- public String platformToolsFilename , buildToolsFilename , platformFilename , toolsFilename , emulatorFilename ;
82
+ public String platformToolsUrl , buildToolsUrl , platformUrl , cmdlineToolsUrl , emulatorUrl ;
83
+ public String platformToolsFilename , buildToolsFilename , platformFilename , cmdlineToolsFilename , emulatorFilename ;
84
84
public String usbDriverUrl ;
85
85
public String usbDriverFilename ;
86
86
public String haxmFilename , haxmUrl ;
@@ -128,9 +128,9 @@ protected Object doInBackground() throws Exception {
128
128
getHaxmDownloadUrl (downloadUrls , haxmUrl , Platform .getName ());
129
129
firePropertyChange (AndroidMode .getTextString ("download_property.change_event_total" ), 0 , downloadUrls .totalSize );
130
130
131
- // tools
132
- File downloadedTools = new File (tempFolder , downloadUrls .toolsFilename );
133
- downloadAndUnpack (downloadUrls .toolsUrl , downloadedTools , sdkFolder , true );
131
+ // command-line tools
132
+ File downloadedCmdLineTools = new File (tempFolder , downloadUrls .cmdlineToolsFilename );
133
+ downloadAndUnpack (downloadUrls .cmdlineToolsUrl , downloadedCmdLineTools , sdkFolder , true );
134
134
135
135
// platform-tools
136
136
File downloadedPlatformTools = new File (tempFolder , downloadUrls .platformToolsFilename );
@@ -246,7 +246,7 @@ private void getMainDownloadUrls(SDKUrlHolder urlHolder,
246
246
boolean found ;
247
247
248
248
// -----------------------------------------------------------------------
249
- // platform
249
+ // Platform
250
250
expr = xpath .compile ("//remotePackage[starts-with(@path, \" platforms;\" )" +
251
251
"and contains(@path, '" + AndroidBuild .TARGET_SDK + "')]" ); // Skip latest platform; download only the targeted
252
252
remotePackages = (NodeList ) expr .evaluate (doc , XPathConstants .NODESET );
@@ -271,12 +271,12 @@ private void getMainDownloadUrls(SDKUrlHolder urlHolder,
271
271
throw new IOException (AndroidMode .getTextString ("sdk_downloader.error_cannot_find_platform_files" ));
272
272
}
273
273
274
- // Difference between platform tools, build tools, and SDK tools:
274
+ // Difference between platform tools, build tools, and SDK (now command-line) tools:
275
275
// http://stackoverflow.com/questions/19911762/what-is-android-sdk-build-tools-and-which-version-should-be-used
276
276
// Always get the latest!
277
277
278
278
// -----------------------------------------------------------------------
279
- // platform- tools
279
+ // Platform tools
280
280
expr = xpath .compile ("//remotePackage[@path=\" platform-tools\" ]" );
281
281
remotePackages = (NodeList ) expr .evaluate (doc , XPathConstants .NODESET );
282
282
if (remotePackages != null ) {
@@ -286,7 +286,7 @@ private void getMainDownloadUrls(SDKUrlHolder urlHolder,
286
286
}
287
287
288
288
// -----------------------------------------------------------------------
289
- // build- tools
289
+ // Build tools
290
290
expr = xpath .compile ("//remotePackage[starts-with(@path, \" build-tools;\" )]" );
291
291
remotePackages = (NodeList ) expr .evaluate (doc , XPathConstants .NODESET );
292
292
found = false ;
@@ -332,14 +332,19 @@ private void getMainDownloadUrls(SDKUrlHolder urlHolder,
332
332
}
333
333
334
334
// -----------------------------------------------------------------------
335
- // tools
336
- expr = xpath .compile ("//remotePackage[@path=\" tools\" ]" ); // Matches two items according to xml file
335
+ // Command-line tools
336
+ // expr = xpath.compile("//remotePackage[@path=\"cmdline-tools;\"]");
337
+ expr = xpath .compile ("//remotePackage[starts-with(@path, \" cmdline-tools;\" )]" );
337
338
remotePackages = (NodeList ) expr .evaluate (doc , XPathConstants .NODESET );
338
339
found = false ;
339
340
if (remotePackages != null ) {
340
341
for (int tool = 0 ; tool < remotePackages .getLength (); tool ++) {
341
342
NodeList childNodes = remotePackages .item (tool ).getChildNodes ();
342
343
344
+ NodeList channel = ((Element ) childNodes ).getElementsByTagName ("channelRef" );
345
+ if (!channel .item (0 ).getAttributes ().item (0 ).getNodeValue ().equals ("channel-0" ))
346
+ continue ; // Stable channel only, skip others
347
+
343
348
NodeList archives = ((Element ) childNodes ).getElementsByTagName ("archive" );
344
349
for (int i = 0 ; i < archives .getLength (); ++i ) {
345
350
NodeList archive = archives .item (i ).getChildNodes ();
@@ -350,45 +355,23 @@ private void getMainDownloadUrls(SDKUrlHolder urlHolder,
350
355
NodeList size = ((Element ) complete .item (0 )).getElementsByTagName ("size" );
351
356
352
357
if (os .item (0 ).getTextContent ().equals (requiredHostOs )) {
353
- urlHolder .toolsFilename = url .item (0 ).getTextContent ();
354
- urlHolder .toolsUrl = REPOSITORY_URL + urlHolder .toolsFilename ;
358
+ urlHolder .cmdlineToolsFilename = url .item (0 ).getTextContent ();
359
+ urlHolder .cmdlineToolsUrl = REPOSITORY_URL + urlHolder .cmdlineToolsFilename ;
355
360
urlHolder .totalSize += Integer .parseInt (size .item (0 ).getTextContent ());
356
361
found = true ;
357
362
break ;
358
363
}
359
364
}
360
365
if (found ) break ;
361
366
}
362
-
363
- // NodeList childNodes = remotePackages.item(1).getChildNodes(); // Second item is the latest tools for now
364
- // NodeList archives = ((Element) childNodes).getElementsByTagName("archive");
365
- //
366
- // for (int i = 0; i < archives.getLength(); ++i) {
367
- // NodeList archive = archives.item(i).getChildNodes();
368
- // NodeList complete = ((Element) archive).getElementsByTagName("complete");
369
- //
370
- // NodeList os = ((Element) archive).getElementsByTagName("host-os");
371
- // NodeList url = ((Element) complete.item(0)).getElementsByTagName("url");
372
- // NodeList size = ((Element) complete.item(0)).getElementsByTagName("size");
373
- //
374
- // if (os.item(0).getTextContent().equals(requiredHostOs)) {
375
- // urlHolder.toolsFilename = url.item(0).getTextContent();
376
- // urlHolder.toolsUrl = REPOSITORY_URL + urlHolder.toolsFilename;
377
- // urlHolder.totalSize += Integer.parseInt(size.item(0).getTextContent());
378
- // found = true;
379
- // break;
380
- // }
381
- // }
382
-
383
-
384
367
}
385
368
if (!found ) {
386
369
throw new IOException (AndroidMode .getTextString ("sdk_downloader.error_cannot_find_tools" ));
387
370
}
388
371
389
372
// -----------------------------------------------------------------------
390
- // emulator
391
- expr = xpath .compile ("//remotePackage[@path=\" emulator\" ]" ); // Matches two items according to xml file
373
+ // Emulator
374
+ expr = xpath .compile ("//remotePackage[@path=\" emulator\" ]" );
392
375
remotePackages = (NodeList ) expr .evaluate (doc , XPathConstants .NODESET );
393
376
found = false ;
394
377
if (remotePackages != null ) {
0 commit comments