Search in sources :

Example 1 with IAndroidTarget

use of com.android.sdklib.IAndroidTarget 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 IAndroidTarget

use of com.android.sdklib.IAndroidTarget in project kotlin by JetBrains.

the class LintClient method getTargets.

/**
     * Returns all the {@link IAndroidTarget} versions installed in the user's SDK install
     * area.
     *
     * @return all the installed targets
     */
@NonNull
public IAndroidTarget[] getTargets() {
    if (mTargets == null) {
        AndroidSdkHandler sdkHandler = getSdk();
        if (sdkHandler != null) {
            ProgressIndicator logger = getRepositoryLogger();
            Collection<IAndroidTarget> targets = sdkHandler.getAndroidTargetManager(logger).getTargets(logger);
            mTargets = targets.toArray(new IAndroidTarget[targets.size()]);
        } else {
            mTargets = new IAndroidTarget[0];
        }
    }
    return mTargets;
}
Also used : ProgressIndicator(com.android.repository.api.ProgressIndicator) AndroidSdkHandler(com.android.sdklib.repositoryv2.AndroidSdkHandler) IAndroidTarget(com.android.sdklib.IAndroidTarget) NonNull(com.android.annotations.NonNull)

Example 3 with IAndroidTarget

use of com.android.sdklib.IAndroidTarget in project kotlin by JetBrains.

the class LintClient method getCompileTarget.

/**
     * Returns the compile target to use for the given project
     *
     * @param project the project in question
     *
     * @return the compile target to use to build the given project
     */
@Nullable
public IAndroidTarget getCompileTarget(@NonNull Project project) {
    int buildSdk = project.getBuildSdk();
    IAndroidTarget[] targets = getTargets();
    for (int i = targets.length - 1; i >= 0; i--) {
        IAndroidTarget target = targets[i];
        if (target.isPlatform() && target.getVersion().getApiLevel() == buildSdk) {
            return target;
        }
    }
    return null;
}
Also used : IAndroidTarget(com.android.sdklib.IAndroidTarget) Nullable(com.android.annotations.Nullable)

Example 4 with IAndroidTarget

use of com.android.sdklib.IAndroidTarget in project kotlin by JetBrains.

the class Project method readManifest.

/**
     * Initialized the manifest state from the given manifest model
     *
     * @param document the DOM document for the manifest XML document
     */
public void readManifest(@NonNull Document document) {
    Element root = document.getDocumentElement();
    if (root == null) {
        return;
    }
    mPackage = root.getAttribute(ATTR_PACKAGE);
    // shouldn't have to investigate)
    if (mPackage != null && mPackage.startsWith("android.support.")) {
        mReportIssues = false;
    }
    // Initialize minSdk and targetSdk
    mManifestMinSdk = AndroidVersion.DEFAULT;
    mManifestTargetSdk = AndroidVersion.DEFAULT;
    NodeList usesSdks = root.getElementsByTagName(TAG_USES_SDK);
    if (usesSdks.getLength() > 0) {
        Element element = (Element) usesSdks.item(0);
        String minSdk = null;
        if (element.hasAttributeNS(ANDROID_URI, ATTR_MIN_SDK_VERSION)) {
            minSdk = element.getAttributeNS(ANDROID_URI, ATTR_MIN_SDK_VERSION);
        }
        if (minSdk != null) {
            IAndroidTarget[] targets = mClient.getTargets();
            mManifestMinSdk = SdkVersionInfo.getVersion(minSdk, targets);
        }
        if (element.hasAttributeNS(ANDROID_URI, ATTR_TARGET_SDK_VERSION)) {
            String targetSdk = element.getAttributeNS(ANDROID_URI, ATTR_TARGET_SDK_VERSION);
            if (targetSdk != null) {
                IAndroidTarget[] targets = mClient.getTargets();
                mManifestTargetSdk = SdkVersionInfo.getVersion(targetSdk, targets);
            }
        } else {
            mManifestTargetSdk = mManifestMinSdk;
        }
    } else if (isAospBuildEnvironment()) {
        extractAospMinSdkVersion();
        mManifestTargetSdk = mManifestMinSdk;
    }
}
Also used : Element(org.w3c.dom.Element) NodeList(org.w3c.dom.NodeList) IAndroidTarget(com.android.sdklib.IAndroidTarget)

Example 5 with IAndroidTarget

use of com.android.sdklib.IAndroidTarget in project android by JetBrains.

the class TemplateTest method testJdk5.

public void testJdk5() throws Exception {
    if (DISABLED) {
        return;
    }
    AndroidSdkData sdkData = AndroidSdks.getInstance().tryToChooseAndroidSdk();
    assertNotNull(sdkData);
    IAndroidTarget[] targets = sdkData.getTargets();
    IAndroidTarget target = targets[targets.length - 1];
    Map<String, Object> overrides = new HashMap<>();
    overrides.put(ATTR_JAVA_VERSION, "1.5");
    NewProjectWizardState state = createNewProjectState(true, sdkData);
    // TODO: Allow null activity state!
    File activity = findTemplate("activities", "BasicActivity");
    TemplateWizardState activityState = state.getActivityTemplateState();
    assertNotNull(activity);
    activityState.setTemplateLocation(activity);
    checkApiTarget(9, 18, target, state, "Test15", null, overrides, null);
}
Also used : AndroidSdkData(org.jetbrains.android.sdk.AndroidSdkData) TemplateWizardState(com.android.tools.idea.wizard.template.TemplateWizardState) IAndroidTarget(com.android.sdklib.IAndroidTarget) NewProjectWizardState(com.android.tools.idea.npw.NewProjectWizardState) VirtualFile(com.intellij.openapi.vfs.VirtualFile) VfsUtilCore.virtualToIoFile(com.intellij.openapi.vfs.VfsUtilCore.virtualToIoFile) File(java.io.File)

Aggregations

IAndroidTarget (com.android.sdklib.IAndroidTarget)105 Nullable (org.jetbrains.annotations.Nullable)24 VirtualFile (com.intellij.openapi.vfs.VirtualFile)19 Module (com.intellij.openapi.module.Module)17 NotNull (org.jetbrains.annotations.NotNull)16 AndroidSdkData (org.jetbrains.android.sdk.AndroidSdkData)15 Sdk (com.intellij.openapi.projectRoots.Sdk)14 File (java.io.File)13 AndroidFacet (org.jetbrains.android.facet.AndroidFacet)13 AndroidPlatform (org.jetbrains.android.sdk.AndroidPlatform)13 AndroidVersion (com.android.sdklib.AndroidVersion)11 Device (com.android.sdklib.devices.Device)11 FolderConfiguration (com.android.ide.common.resources.configuration.FolderConfiguration)9 State (com.android.sdklib.devices.State)8 AndroidSdkAdditionalData (org.jetbrains.android.sdk.AndroidSdkAdditionalData)8 AndroidTargetData (org.jetbrains.android.sdk.AndroidTargetData)8 Configuration (com.android.tools.idea.configurations.Configuration)7 CompatibilityRenderTarget (com.android.tools.idea.rendering.multi.CompatibilityRenderTarget)7 CompilerMessage (org.jetbrains.jps.incremental.messages.CompilerMessage)7 ConfigurationManager (com.android.tools.idea.configurations.ConfigurationManager)6