Search in sources :

Example 1 with SdkManager

use of com.android.sdklib.SdkManager in project otertool by wuntee.

the class AvdWorkshop method createAvd.

public static AvdInfo createAvd(CreateAvdBean bean) throws AndroidLocationException, IOException, GenericException {
    ISdkLog sdkLogger = AvdWorkshop.getAvdLogger();
    SdkManager sdkManager = SdkManager.createManager(OterStatics.getAndroidHome(), sdkLogger);
    AvdManager avdManager = new AvdManager(sdkManager, sdkLogger);
    File avdFolder = new File(AndroidLocation.getFolder() + "avd", bean.getName() + ".avd");
    //newAvdInfo = avdManager.createAvd(avdFolder, avdName, target, skin, this.mSdkCommandLine.getParamSdCard(), hardwareConfig, removePrevious, this.mSdkCommandLine.getFlagSnapshot(), this.mSdkLog);
    IAndroidTarget target = getAndroidTargetFromString(sdkManager, bean.getTarget());
    ISystemImage[] abiTypes = target.getSystemImages();
    if (abiTypes.length == 0) {
        throw new GenericException("There are no images associated with the target.");
    }
    //ABI = Android Base Image ?
    String abiType = abiTypes[0].getAbiType();
    // /Applications/android-sdk-macosx/system-images/android-15/armeabi-v7a//system.img
    // avdManager.           createAvd(avdFolder, avdName,     avdTarget, ABI, skin, sdCard, hadwareConfig, snapshot, force, false, logger)
    //AvdInfo ret = avdManager.createAvd(avdFolder, bean.getName(),           target,        null,        null,                     null,        false,        false, sdkLogger);
    //                       createAvd(File arg0, String arg1, IAndroidTarget arg2, String arg3, String arg4, Map<String, String> arg5, boolean arg6, boolean arg7, ISdkLog arg8)
    AvdInfo ret = avdManager.createAvd(avdFolder, bean.getName(), target, abiType, null, null, null, false, false, false, sdkLogger);
    if (ret == null) {
        logger.error("There was an error createing AVD, the manager returned a null info object.");
        throw new GenericException("Could not create AVD for an unknown reason.");
    }
    if (bean.isPersistant() == true) {
        makeAvdPersistant(ret);
    }
    return (ret);
}
Also used : AvdManager(com.android.sdklib.internal.avd.AvdManager) SdkManager(com.android.sdklib.SdkManager) AvdInfo(com.android.sdklib.internal.avd.AvdInfo) IAndroidTarget(com.android.sdklib.IAndroidTarget) ISystemImage(com.android.sdklib.ISystemImage) File(java.io.File) GenericException(com.wuntee.oter.exception.GenericException) ISdkLog(com.android.sdklib.ISdkLog)

Example 2 with SdkManager

use of com.android.sdklib.SdkManager in project otertool by wuntee.

the class CreateAvdDialog method addTargets.

private void addTargets(Combo combo) {
    ISdkLog sdkLogger = new ISdkLog() {

        public void error(Throwable t, String errorFormat, Object[] args) {
            logger.error("Error: ", t);
        }

        public void warning(String warningFormat, Object[] args) {
            logger.warn(args);
        }

        public void printf(String msgFormat, Object[] args) {
            logger.debug(args);
        }
    };
    SdkManager sdkManager = SdkManager.createManager(OterStatics.getAndroidHome(), sdkLogger);
    IAndroidTarget[] targets = sdkManager.getTargets();
    for (IAndroidTarget target : targets) {
        combo.add(target.hashString());
    }
}
Also used : SdkManager(com.android.sdklib.SdkManager) IAndroidTarget(com.android.sdklib.IAndroidTarget) ISdkLog(com.android.sdklib.ISdkLog)

Example 3 with SdkManager

use of com.android.sdklib.SdkManager in project otertool by wuntee.

the class AvdWorkshop method isAvdExist.

public static boolean isAvdExist(String avd) throws AndroidLocationException {
    ISdkLog sdkLogger = AvdWorkshop.getAvdLogger();
    SdkManager sdkManager = SdkManager.createManager(OterStatics.getAndroidHome(), sdkLogger);
    AvdManager avdManager = new AvdManager(sdkManager, sdkLogger);
    for (AvdInfo i : avdManager.getAllAvds()) {
        if (i.getName().equals(avd)) {
            return (true);
        }
    }
    return (false);
}
Also used : AvdManager(com.android.sdklib.internal.avd.AvdManager) SdkManager(com.android.sdklib.SdkManager) AvdInfo(com.android.sdklib.internal.avd.AvdInfo) ISdkLog(com.android.sdklib.ISdkLog)

Aggregations

ISdkLog (com.android.sdklib.ISdkLog)3 SdkManager (com.android.sdklib.SdkManager)3 IAndroidTarget (com.android.sdklib.IAndroidTarget)2 AvdInfo (com.android.sdklib.internal.avd.AvdInfo)2 AvdManager (com.android.sdklib.internal.avd.AvdManager)2 ISystemImage (com.android.sdklib.ISystemImage)1 GenericException (com.wuntee.oter.exception.GenericException)1 File (java.io.File)1