Search in sources :

Example 1 with LaunchCompatibility

use of com.android.tools.idea.run.LaunchCompatibility in project android by JetBrains.

the class EmulatorTargetConfigurable method getAvdCompatibilityWarning.

@Nullable
private String getAvdCompatibilityWarning() {
    IdDisplay selectedItem = (IdDisplay) myAvdCombo.getComboBox().getSelectedItem();
    if (selectedItem != null) {
        final String selectedAvdName = selectedItem.getId();
        final Module module = myContext.getModule();
        if (module == null) {
            return null;
        }
        final AndroidFacet facet = AndroidFacet.getInstance(module);
        if (facet == null) {
            return null;
        }
        final AvdManager avdManager = facet.getAvdManagerSilently();
        if (avdManager == null) {
            return null;
        }
        final AvdInfo avd = avdManager.getAvd(selectedAvdName, false);
        if (avd == null || avd.getSystemImage() == null) {
            return null;
        }
        AndroidPlatform platform = facet.getConfiguration().getAndroidPlatform();
        if (platform == null) {
            return null;
        }
        AndroidVersion minSdk = AndroidModuleInfo.get(facet).getRuntimeMinSdkVersion();
        LaunchCompatibility compatibility = LaunchCompatibility.canRunOnAvd(minSdk, platform.getTarget(), avd.getSystemImage());
        if (compatibility.isCompatible() == ThreeState.NO) {
            // todo: provide info about current module configuration
            return String.format("'%1$s' may be incompatible with your configuration (%2$s)", selectedAvdName, StringUtil.notNullize(compatibility.getReason()));
        }
    }
    return null;
}
Also used : IdDisplay(com.android.sdklib.repository.IdDisplay) LaunchCompatibility(com.android.tools.idea.run.LaunchCompatibility) AvdManager(com.android.sdklib.internal.avd.AvdManager) AvdInfo(com.android.sdklib.internal.avd.AvdInfo) AndroidPlatform(org.jetbrains.android.sdk.AndroidPlatform) Module(com.intellij.openapi.module.Module) AndroidVersion(com.android.sdklib.AndroidVersion) AndroidFacet(org.jetbrains.android.facet.AndroidFacet) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

AndroidVersion (com.android.sdklib.AndroidVersion)1 AvdInfo (com.android.sdklib.internal.avd.AvdInfo)1 AvdManager (com.android.sdklib.internal.avd.AvdManager)1 IdDisplay (com.android.sdklib.repository.IdDisplay)1 LaunchCompatibility (com.android.tools.idea.run.LaunchCompatibility)1 Module (com.intellij.openapi.module.Module)1 AndroidFacet (org.jetbrains.android.facet.AndroidFacet)1 AndroidPlatform (org.jetbrains.android.sdk.AndroidPlatform)1 Nullable (org.jetbrains.annotations.Nullable)1