Skip to content

Commit 8cd565d

Browse files
committed
Merge pull request #144 from omerjerk/bugfix_sdk
fix automatic download of android sdk for newer API level
2 parents 2f1ab4e + 11f5c56 commit 8cd565d

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/processing/mode/android/SDKDownloader.java

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import java.beans.PropertyChangeEvent;
2424
import java.beans.PropertyChangeListener;
2525
import java.io.*;
26+
import java.net.MalformedURLException;
2627
import java.net.URL;
2728
import java.net.URLConnection;
2829
import java.util.Enumeration;
@@ -32,7 +33,7 @@
3233
@SuppressWarnings("serial")
3334
public class SDKDownloader extends JFrame implements PropertyChangeListener {
3435

35-
private static final String URL_REPOSITORY = "https://dl-ssl.google.com/android/repository/repository-10.xml";
36+
private static final String URL_REPOSITORY = "https://dl-ssl.google.com/android/repository/repository-11.xml";
3637
private static final String URL_REPOSITORY_FOLDER = "http://dl-ssl.google.com/android/repository/";
3738
private static final String URL_USB_DRIVER = "https://dl-ssl.google.com//android/repository/latest_usb_driver_windows.zip";
3839

@@ -135,7 +136,19 @@ protected void done() {
135136

136137
private void downloadAndUnpack(String urlString, File saveTo,
137138
File unpackTo) throws IOException {
138-
URL url = new URL(urlString);
139+
URL url = null;
140+
try {
141+
url = new URL(urlString);
142+
} catch (MalformedURLException e) {
143+
//This is expected for API level 14 and more
144+
try {
145+
url = new URL(URL_REPOSITORY_FOLDER + urlString);
146+
} catch (MalformedURLException e1) {
147+
//This exception is not expected. Need to return.
148+
e1.printStackTrace();
149+
return;
150+
}
151+
}
139152
URLConnection conn = url.openConnection();
140153

141154
InputStream inputStream = conn.getInputStream();

0 commit comments

Comments
 (0)