Skip to content

Commit e5faea6

Browse files
committed
hardcode max tool versions to avoid breaking the mode
1 parent a591e0d commit e5faea6

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

src/processing/mode/android/SDKDownloader.java

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,15 @@
5252
public class SDKDownloader extends JDialog implements PropertyChangeListener {
5353
// Version 25.3.1 of the SDK tools break the mode, since the android tool
5454
// no longer works:
55+
private static final int SDK_TOOLS_MAX_MAJOR = 25;
56+
private static final int SDK_TOOLS_MAX_MINOR = 2;
57+
58+
private static final int PLATFORM_TOOLS_MAX_MAJOR = 25;
59+
private static final int PLATFORM_TOOLS_MAX_MINOR = 0;
60+
61+
private static final int BUILD_TOOLS_MAX_MAJOR = 25;
62+
private static final int BUILD_TOOLS_MAX_MINOR = 0;
63+
5564
// https://code.google.com/p/android/issues/detail?id=235455
5665
// as well as removing the ant scripts.
5766
// https://code.google.com/p/android/issues/detail?id=235410
@@ -250,7 +259,7 @@ private void getMainDownloadUrls(SDKUrlHolder urlHolder,
250259

251260
// -----------------------------------------------------------------------
252261
// platform-tools
253-
Node platformToolsItem = getLatestToolItem(doc.getElementsByTagName("sdk:platform-tool"));
262+
Node platformToolsItem = getLatestToolItem(doc.getElementsByTagName("sdk:platform-tool"), PLATFORM_TOOLS_MAX_MAJOR, PLATFORM_TOOLS_MAX_MINOR);
254263
if (platformToolsItem != null) {
255264
archiveListItem = ((Element) platformToolsItem).getElementsByTagName("sdk:archives").item(0);
256265
archiveList = ((Element) archiveListItem).getElementsByTagName("sdk:archive");
@@ -268,12 +277,12 @@ private void getMainDownloadUrls(SDKUrlHolder urlHolder,
268277

269278
// -----------------------------------------------------------------------
270279
// build-tools
271-
Node buildToolsItem = getLatestToolItem(doc.getElementsByTagName("sdk:build-tool"));
280+
Node buildToolsItem = getLatestToolItem(doc.getElementsByTagName("sdk:build-tool"), BUILD_TOOLS_MAX_MAJOR, BUILD_TOOLS_MAX_MINOR);
272281
if (buildToolsItem != null) {
273282
Node revisionListItem = ((Element) buildToolsItem).getElementsByTagName("sdk:revision").item(0);
274283
String major = ((Element) revisionListItem).getElementsByTagName("sdk:major").item(0).getTextContent();
275284
String minor = ((Element) revisionListItem).getElementsByTagName("sdk:minor").item(0).getTextContent();
276-
String micro = ((Element) revisionListItem).getElementsByTagName("sdk:micro").item(0).getTextContent();
285+
String micro = ((Element) revisionListItem).getElementsByTagName("sdk:micro").item(0).getTextContent();
277286
urlHolder.buildToolsVersion = major + "." + minor + "." + micro;
278287
archiveListItem = ((Element) buildToolsItem).getElementsByTagName("sdk:archives").item(0);
279288
archiveList = ((Element) archiveListItem).getElementsByTagName("sdk:archive");
@@ -291,7 +300,7 @@ private void getMainDownloadUrls(SDKUrlHolder urlHolder,
291300

292301
// -----------------------------------------------------------------------
293302
// tools
294-
Node toolsItem = getLatestToolItem(doc.getElementsByTagName("sdk:tool"));
303+
Node toolsItem = getLatestToolItem(doc.getElementsByTagName("sdk:tool"), SDK_TOOLS_MAX_MAJOR, SDK_TOOLS_MAX_MINOR);;
295304
if (toolsItem != null) {
296305
archiveListItem = ((Element) toolsItem).getElementsByTagName("sdk:archives").item(0);
297306
archiveList = ((Element) archiveListItem).getElementsByTagName("sdk:archive");
@@ -384,7 +393,7 @@ private Node getLatestPlatform(NodeList platformList) {
384393
return latest;
385394
}
386395

387-
private Node getLatestToolItem(NodeList list) {
396+
private Node getLatestToolItem(NodeList list, int max_major, int max_minor) {
388397
Node latest = null;
389398
int maxMajor = -1;
390399
int maxMinor = -1;
@@ -397,7 +406,8 @@ private Node getLatestToolItem(NodeList list) {
397406
NodeList micro = ((Element)revision).getElementsByTagName("sdk:micro");
398407
int intMajor = PApplet.parseInt(major.item(0).getTextContent());
399408
int intMinor = PApplet.parseInt(minor.item(0).getTextContent());
400-
int intMicro = PApplet.parseInt(micro.item(0).getTextContent());
409+
int intMicro = PApplet.parseInt(micro.item(0).getTextContent());
410+
if (max_major < intMajor || (max_major == intMajor && max_minor < intMinor)) continue;
401411
if (maxMajor <= intMajor && maxMinor <= intMinor && maxMicro <= intMicro) {
402412
latest = item;
403413
maxMajor = intMajor;

0 commit comments

Comments
 (0)