Skip to content

Commit 4d7bb90

Browse files
committed
check if target ABIs exist
1 parent b9ea3d3 commit 4d7bb90

File tree

2 files changed

+31
-15
lines changed

2 files changed

+31
-15
lines changed

src/processing/mode/android/AVD.java

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,9 @@ protected boolean badness() {
180180
return false;
181181
}
182182

183-
184-
protected boolean create(final AndroidSDK sdk) throws IOException {
185-
183+
184+
protected void initTargets(final AndroidSDK sdk) throws IOException {
185+
preferredAbi.clear();
186186
final String[] list_abi = {
187187
sdk.getAndroidToolPath(),
188188
"list", "targets"
@@ -213,6 +213,7 @@ protected boolean create(final AndroidSDK sdk) throws IOException {
213213

214214
if (api != null && abis != null) {
215215
for (String abi: abis) {
216+
if (abiList.indexOf(abi) == -1) continue;
216217
if (preferredAbi.get(api) == null) {
217218
preferredAbi.put(api, abi);
218219
} else if (abiList.indexOf(preferredAbi.get(api)) < abiList.indexOf(abi)) {
@@ -243,7 +244,18 @@ protected boolean create(final AndroidSDK sdk) throws IOException {
243244
// }
244245
// }
245246
}
246-
} catch (InterruptedException e) {}
247+
} catch (InterruptedException e) {}
248+
}
249+
250+
251+
protected boolean noTargets(final AndroidSDK sdk) throws IOException {
252+
initTargets(sdk);
253+
return preferredAbi.size() == 0;
254+
}
255+
256+
257+
protected boolean create(final AndroidSDK sdk) throws IOException {
258+
initTargets(sdk);
247259

248260
final String[] params = {
249261
sdk.getAndroidToolPath(),
@@ -261,7 +273,7 @@ protected boolean create(final AndroidSDK sdk) throws IOException {
261273
// Set the list to null so that exists() will check again
262274
avdList = null;
263275

264-
p = new ProcessHelper(params);
276+
ProcessHelper p = new ProcessHelper(params);
265277
try {
266278
// Passes 'no' to "Do you wish to create a custom hardware profile [no]"
267279
final ProcessResult createAvdResult = p.execute("no");
@@ -286,19 +298,21 @@ protected boolean create(final AndroidSDK sdk) throws IOException {
286298

287299
static public boolean ensureProperAVD(final Frame window, final AndroidMode mode,
288300
final AndroidSDK sdk) {
289-
try {
290-
301+
try {
291302
if (AndroidBuild.appComponent == AndroidBuild.WATCHFACE) {
292303
if (wearAVD.exists(sdk)) {
293304
return true;
294305
}
295306
if (wearAVD.badness()) {
307+
Messages.showWarningTiered("Android Error", AVD_LOAD_PRIMARY, AVD_LOAD_SECONDARY, null);
308+
return false;
309+
}
310+
if (wearAVD.noTargets(sdk)) {
296311
boolean res = AndroidSDK.locateSysImage(window, mode, true);
297312
if (!res) {
298-
Messages.showWarningTiered("Android Error", AVD_LOAD_PRIMARY, AVD_LOAD_SECONDARY, null);
299-
return false;
313+
return false;
300314
}
301-
}
315+
}
302316
if (wearAVD.create(sdk)) {
303317
return true;
304318
}
@@ -307,17 +321,19 @@ static public boolean ensureProperAVD(final Frame window, final AndroidMode mode
307321
return true;
308322
}
309323
if (defaultAVD.badness()) {
324+
Messages.showWarningTiered("Android Error", AVD_LOAD_PRIMARY, AVD_LOAD_SECONDARY, null);
325+
return false;
326+
}
327+
if (defaultAVD.noTargets(sdk)) {
310328
boolean res = AndroidSDK.locateSysImage(window, mode, false);
311329
if (!res) {
312-
Messages.showWarningTiered("Android Error", AVD_LOAD_PRIMARY, AVD_LOAD_SECONDARY, null);
313-
return false;
330+
return false;
314331
}
315-
}
332+
}
316333
if (defaultAVD.create(sdk)) {
317334
return true;
318335
}
319336
}
320-
321337
} catch (final Exception e) {
322338
Messages.showWarningTiered("Android Error", AVD_CREATE_PRIMARY,
323339
String.format(AVD_CREATE_SECONDARY,

src/processing/mode/android/SysImageDownloader.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ public static String humanReadableByteCount(long bytes, boolean si) {
260260
}
261261

262262
public SysImageDownloader(Frame editor, AndroidMode mode, boolean wear) {
263-
super(editor, "SDK download", true);
263+
super(editor, "Emulator download", true);
264264
this.editor = editor;
265265
this.mode = mode;
266266
this.wear = wear;

0 commit comments

Comments
 (0)