@@ -81,7 +81,7 @@ public class AVD {
81
81
private String skin ;
82
82
83
83
/** Default virtual device used by Processing. */
84
- static public final AVD defaultAVD =
84
+ static public final AVD mobileAVD =
85
85
new AVD ("Processing-0" + Base .getRevision (),
86
86
AndroidBuild .target_platform , SysImageDownloader .SYSTEM_IMAGE_TAG , DEFAULT_SKIN );
87
87
// "Google Inc.:Google APIs:" + AndroidBuild.sdkVersion);
@@ -198,19 +198,25 @@ protected void initTargets(final AndroidSDK sdk) throws IOException {
198
198
line = line .trim ();
199
199
if (line .equals ("" )) continue ;
200
200
201
- if (-1 < line .indexOf ("API level" )) {
202
- api = line .split (":" )[1 ];
203
- api = api .trim ();
201
+ if (line .indexOf ("API level" ) == 0 ) {
202
+ String [] m = line .split (":" );
203
+ if (1 < m .length ) {
204
+ api = m [1 ];
205
+ api = api .trim ();
206
+ }
204
207
}
205
208
206
- if (-1 < line .indexOf ("Tag/ABIs" )) {
207
- String str = line .split (":" )[1 ];
208
- abis = str .split ("," );
209
- for (int i = 0 ; i < abis .length ; i ++) {
210
- abis [i ] = abis [i ].trim ();
209
+ if (line .indexOf ("Tag/ABIs" ) == 0 ) {
210
+ String [] m = line .split (":" );
211
+ if (1 < m .length ) {
212
+ String str = m [1 ];
213
+ abis = str .split ("," );
214
+ for (int i = 0 ; i < abis .length ; i ++) {
215
+ abis [i ] = abis [i ].trim ();
216
+ }
211
217
}
212
218
}
213
-
219
+
214
220
if (api != null && abis != null ) {
215
221
for (String abi : abis ) {
216
222
if (abiList .indexOf (abi ) == -1 ) continue ;
@@ -223,34 +229,16 @@ protected void initTargets(final AndroidSDK sdk) throws IOException {
223
229
api = null ;
224
230
abis = null ;
225
231
}
226
-
227
- // String[] m = PApplet.match(line, "API\\slevel:\\s(\\S+)");
228
- // if (m != null) {
229
- // api = m[1];
230
- // }
231
- //
232
- // m = PApplet.match(line, "Tag\\/ABIs\\s:\\sdefault\\/(\\S+)");
233
- // if (m != null) {
234
- // abi = m[1];
235
- //
236
- // if (api != null && abi != null) {
237
- // if (preferredAbi.get(api) == null) {
238
- // preferredAbi.put(api, abi);
239
- // } else if (abiList.indexOf(preferredAbi.get(api)) < abiList.indexOf(abi)) {
240
- // preferredAbi.put(api, abi);
241
- // }
242
- // api = null;
243
- // abi = null;
244
- // }
245
- // }
246
232
}
247
- } catch (InterruptedException e ) {}
233
+ } catch (InterruptedException e ) {
234
+ }
248
235
}
249
236
250
237
251
238
protected boolean noTargets (final AndroidSDK sdk ) throws IOException {
252
239
initTargets (sdk );
253
- return preferredAbi .size () == 0 ;
240
+ // return preferredAbi.size() == 0;
241
+ return preferredAbi .get (AndroidBuild .target_sdk ) == null ;
254
242
}
255
243
256
244
@@ -267,15 +255,15 @@ protected boolean create(final AndroidSDK sdk) throws IOException {
267
255
"--abi" , preferredAbi .get (AndroidBuild .target_sdk )
268
256
};
269
257
270
- //sdk/tools/android create avd -n "Wear-Processing-0254" -t android-23 -c 64M -s AndroidWearSquare --abi android-wear/x86
271
-
272
-
258
+ // sdk/tools/android create avd -n "Wear-Processing-0254" -t android-23 -c 64M -s AndroidWearSquare --abi android-wear/x86
259
+
273
260
// Set the list to null so that exists() will check again
274
261
avdList = null ;
275
-
262
+
276
263
ProcessHelper p = new ProcessHelper (params );
277
264
try {
278
265
// Passes 'no' to "Do you wish to create a custom hardware profile [no]"
266
+
279
267
final ProcessResult createAvdResult = p .execute ("no" );
280
268
if (createAvdResult .succeeded ()) {
281
269
return true ;
@@ -286,10 +274,13 @@ protected boolean create(final AndroidSDK sdk) throws IOException {
286
274
} else {
287
275
// Just generally not working
288
276
Messages .showWarningTiered ("Android Error" , AVD_CREATE_PRIMARY , AVD_CREATE_SECONDARY , null );
277
+ // Messages.showWarningTiered("Android Error", AVD_CREATE_PRIMARY, "UCKCUCKKDKDDKD", null);
289
278
System .out .println (createAvdResult );
290
279
}
291
280
//System.err.println(createAvdResult);
292
- } catch (final InterruptedException ie ) { }
281
+ } catch (final InterruptedException ie ) {
282
+ ie .printStackTrace ();
283
+ }
293
284
294
285
return false ;
295
286
}
@@ -314,7 +305,7 @@ static public boolean ensureProperAVD(final Frame window, final AndroidMode mode
314
305
return false ;
315
306
}
316
307
if (wearAVD .noTargets (sdk )) {
317
- boolean res = AndroidSDK .locateSysImage (window , mode , true );
308
+ boolean res = AndroidSDK .locateSysImage (window , mode , true );
318
309
if (!res ) {
319
310
return false ;
320
311
}
@@ -323,24 +314,25 @@ static public boolean ensureProperAVD(final Frame window, final AndroidMode mode
323
314
return true ;
324
315
}
325
316
} else {
326
- if (defaultAVD .exists (sdk )) {
317
+ if (mobileAVD .exists (sdk )) {
327
318
return true ;
328
319
}
329
- if (defaultAVD .badness ()) {
320
+ if (mobileAVD .badness ()) {
330
321
Messages .showWarningTiered ("Android Error" , AVD_LOAD_PRIMARY , AVD_LOAD_SECONDARY , null );
331
322
return false ;
332
- }
333
- if (defaultAVD .noTargets (sdk )) {
323
+ }
324
+ if (mobileAVD .noTargets (sdk )) {
334
325
boolean res = AndroidSDK .locateSysImage (window , mode , false );
335
326
if (!res ) {
336
327
return false ;
337
328
}
338
329
}
339
- if (defaultAVD .create (sdk )) {
330
+ if (mobileAVD .create (sdk )) {
340
331
return true ;
341
332
}
342
333
}
343
334
} catch (final Exception e ) {
335
+ e .printStackTrace ();
344
336
Messages .showWarningTiered ("Android Error" , AVD_CREATE_PRIMARY ,
345
337
String .format (AVD_CREATE_SECONDARY ,
346
338
AndroidBuild .target_sdk ), null );
0 commit comments