Search in sources :

Example 1 with GenericException

use of com.wuntee.oter.exception.GenericException 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)

Aggregations

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