protected boolean create(final AndroidSDK sdk) throws IOException { final String[] params = { sdk.getAndroidToolPath(), "create", "avd", "-n", name, "-t", target, "-c", DEFAULT_SDCARD_SIZE, "-s", DEFAULT_SKIN, "--abi", "armeabi" }; // Set the list to null so that exists() will check again avdList = null; final ProcessHelper p = new ProcessHelper(params); try { // Passes 'no' to "Do you wish to create a custom hardware profile [no]" // System.out.println("CREATE AVD STARTING"); final ProcessResult createAvdResult = p.execute("no"); // System.out.println("CREATE AVD HAS COMPLETED"); if (createAvdResult.succeeded()) { return true; } if (createAvdResult.toString().contains("Target id is not valid")) { // They didn't install the Google APIs Base.showWarningTiered("Android Error", AVD_TARGET_PRIMARY, AVD_TARGET_SECONDARY, null); // throw new IOException("Missing required SDK components"); } else { // Just generally not working // Base.showWarning("Android Error", AVD_CREATE_ERROR, null); Base.showWarningTiered("Android Error", AVD_CREATE_PRIMARY, AVD_CREATE_SECONDARY, null); System.out.println(createAvdResult); // throw new IOException("Error creating the AVD"); } // System.err.println(createAvdResult); } catch (final InterruptedException ie) { } return false; }
protected static void list(final AndroidSDK sdk) throws IOException { try { avdList = new ArrayList<String>(); badList = new ArrayList<String>(); ProcessResult listResult = new ProcessHelper(sdk.getAndroidToolPath(), "list", "avds").execute(); if (listResult.succeeded()) { boolean badness = false; for (String line : listResult) { String[] m = PApplet.match(line, "\\s+Name\\:\\s+(\\S+)"); if (m != null) { if (!badness) { // System.out.println("good: " + m[1]); avdList.add(m[1]); } else { // System.out.println("bad: " + m[1]); badList.add(m[1]); } // } else { // System.out.println("nope: " + line); } // "The following Android Virtual Devices could not be loaded:" if (line.contains("could not be loaded:")) { // System.out.println("starting the bad list"); // System.err.println("Could not list AVDs:"); // System.err.println(listResult); badness = true; // break; } } } else { System.err.println("Unhappy inside exists()"); System.err.println(listResult); } } catch (final InterruptedException ie) { } }