@@ -81,7 +81,7 @@ public class AVD {
8181 private String skin ;
8282
8383 /** Default virtual device used by Processing. */
84- static public final AVD defaultAVD =
84+ static public final AVD mobileAVD =
8585 new AVD ("Processing-0" + Base .getRevision (),
8686 AndroidBuild .target_platform , SysImageDownloader .SYSTEM_IMAGE_TAG , DEFAULT_SKIN );
8787// "Google Inc.:Google APIs:" + AndroidBuild.sdkVersion);
@@ -198,19 +198,25 @@ protected void initTargets(final AndroidSDK sdk) throws IOException {
198198 line = line .trim ();
199199 if (line .equals ("" )) continue ;
200200
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+ }
204207 }
205208
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+ }
211217 }
212218 }
213-
219+
214220 if (api != null && abis != null ) {
215221 for (String abi : abis ) {
216222 if (abiList .indexOf (abi ) == -1 ) continue ;
@@ -223,34 +229,16 @@ protected void initTargets(final AndroidSDK sdk) throws IOException {
223229 api = null ;
224230 abis = null ;
225231 }
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- // }
246232 }
247- } catch (InterruptedException e ) {}
233+ } catch (InterruptedException e ) {
234+ }
248235 }
249236
250237
251238 protected boolean noTargets (final AndroidSDK sdk ) throws IOException {
252239 initTargets (sdk );
253- return preferredAbi .size () == 0 ;
240+ // return preferredAbi.size() == 0;
241+ return preferredAbi .get (AndroidBuild .target_sdk ) == null ;
254242 }
255243
256244
@@ -267,15 +255,15 @@ protected boolean create(final AndroidSDK sdk) throws IOException {
267255 "--abi" , preferredAbi .get (AndroidBuild .target_sdk )
268256 };
269257
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+
273260 // Set the list to null so that exists() will check again
274261 avdList = null ;
275-
262+
276263 ProcessHelper p = new ProcessHelper (params );
277264 try {
278265 // Passes 'no' to "Do you wish to create a custom hardware profile [no]"
266+
279267 final ProcessResult createAvdResult = p .execute ("no" );
280268 if (createAvdResult .succeeded ()) {
281269 return true ;
@@ -286,10 +274,13 @@ protected boolean create(final AndroidSDK sdk) throws IOException {
286274 } else {
287275 // Just generally not working
288276 Messages .showWarningTiered ("Android Error" , AVD_CREATE_PRIMARY , AVD_CREATE_SECONDARY , null );
277+ // Messages.showWarningTiered("Android Error", AVD_CREATE_PRIMARY, "UCKCUCKKDKDDKD", null);
289278 System .out .println (createAvdResult );
290279 }
291280 //System.err.println(createAvdResult);
292- } catch (final InterruptedException ie ) { }
281+ } catch (final InterruptedException ie ) {
282+ ie .printStackTrace ();
283+ }
293284
294285 return false ;
295286 }
@@ -314,7 +305,7 @@ static public boolean ensureProperAVD(final Frame window, final AndroidMode mode
314305 return false ;
315306 }
316307 if (wearAVD .noTargets (sdk )) {
317- boolean res = AndroidSDK .locateSysImage (window , mode , true );
308+ boolean res = AndroidSDK .locateSysImage (window , mode , true );
318309 if (!res ) {
319310 return false ;
320311 }
@@ -323,24 +314,25 @@ static public boolean ensureProperAVD(final Frame window, final AndroidMode mode
323314 return true ;
324315 }
325316 } else {
326- if (defaultAVD .exists (sdk )) {
317+ if (mobileAVD .exists (sdk )) {
327318 return true ;
328319 }
329- if (defaultAVD .badness ()) {
320+ if (mobileAVD .badness ()) {
330321 Messages .showWarningTiered ("Android Error" , AVD_LOAD_PRIMARY , AVD_LOAD_SECONDARY , null );
331322 return false ;
332- }
333- if (defaultAVD .noTargets (sdk )) {
323+ }
324+ if (mobileAVD .noTargets (sdk )) {
334325 boolean res = AndroidSDK .locateSysImage (window , mode , false );
335326 if (!res ) {
336327 return false ;
337328 }
338329 }
339- if (defaultAVD .create (sdk )) {
330+ if (mobileAVD .create (sdk )) {
340331 return true ;
341332 }
342333 }
343334 } catch (final Exception e ) {
335+ e .printStackTrace ();
344336 Messages .showWarningTiered ("Android Error" , AVD_CREATE_PRIMARY ,
345337 String .format (AVD_CREATE_SECONDARY ,
346338 AndroidBuild .target_sdk ), null );
0 commit comments