Search in sources :

Example 1 with AndroidVersion

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

the class Project method getResourceFolders.

/**
     * Returns the resource folders.
     *
     * @return a list of files pointing to the resource folders, which might be empty if the project
     * does not provide any resources.
     */
@NonNull
public List<File> getResourceFolders() {
    if (mResourceFolders == null) {
        List<File> folders = mClient.getResourceFolders(this);
        if (folders.size() == 1 && isAospFrameworksRelatedProject(mDir)) {
            // No manifest file for this project: just init the manifest values here
            mManifestMinSdk = mManifestTargetSdk = new AndroidVersion(HIGHEST_KNOWN_API, null);
            File folder = new File(folders.get(0), RES_FOLDER);
            if (!folder.exists()) {
                folders = Collections.emptyList();
            }
        }
        mResourceFolders = folders;
    }
    return mResourceFolders;
}
Also used : AndroidVersion(com.android.sdklib.AndroidVersion) OutputFile(com.android.build.OutputFile) File(java.io.File) NonNull(com.android.annotations.NonNull)

Example 2 with AndroidVersion

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

the class Project method findCurrentAospVersion.

/** In an AOSP build environment, identify the currently built image version, if available */
private static AndroidVersion findCurrentAospVersion() {
    if (sCurrentVersion == null) {
        File versionMk = new File(getAospTop(), //$NON-NLS-1$
        "build/core/version_defaults.mk".replace('/', File.separatorChar));
        if (!versionMk.exists()) {
            sCurrentVersion = AndroidVersion.DEFAULT;
            return sCurrentVersion;
        }
        int sdkVersion = LOWEST_ACTIVE_API;
        try {
            Pattern p = Pattern.compile("PLATFORM_SDK_VERSION\\s*:=\\s*(.*)");
            List<String> lines = Files.readLines(versionMk, Charsets.UTF_8);
            for (String line : lines) {
                line = line.trim();
                Matcher matcher = p.matcher(line);
                if (matcher.matches()) {
                    String version = matcher.group(1);
                    try {
                        sdkVersion = Integer.parseInt(version);
                    } catch (NumberFormatException nfe) {
                    // pass
                    }
                    break;
                }
            }
        } catch (IOException io) {
        // pass
        }
        sCurrentVersion = new AndroidVersion(sdkVersion, null);
    }
    return sCurrentVersion;
}
Also used : Pattern(java.util.regex.Pattern) Matcher(java.util.regex.Matcher) CharMatcher(com.google.common.base.CharMatcher) IOException(java.io.IOException) AndroidVersion(com.android.sdklib.AndroidVersion) OutputFile(com.android.build.OutputFile) File(java.io.File)

Example 3 with AndroidVersion

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

the class MakeBeforeRunTaskProviderTest method previewDeviceArguments.

@Test
public void previewDeviceArguments() {
    when(myDevice.getVersion()).thenReturn(new AndroidVersion(23, "N"));
    when(myDevice.getDensity()).thenReturn(640);
    when(myDevice.getAbis()).thenReturn(ImmutableList.of(Abi.ARMEABI));
    List<String> arguments = MakeBeforeRunTaskProvider.getDeviceSpecificArguments(Collections.singletonList(myDevice));
    assertTrue(arguments.contains("-Pandroid.injected.build.api=24"));
}
Also used : AndroidVersion(com.android.sdklib.AndroidVersion) Test(org.junit.Test)

Example 4 with AndroidVersion

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

the class AndroidVersionsInfoTest method setUp.

@Before
public void setUp() throws Exception {
    initMocks(this);
    Mockito.when(myMockAndroidVersionsInfo.getHighestInstalledVersion()).thenReturn(new AndroidVersion(HIGHEST_VERSION, null));
}
Also used : AndroidVersion(com.android.sdklib.AndroidVersion) Before(org.junit.Before)

Example 5 with AndroidVersion

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

the class LaunchCompatibilityTest method testMinSdk.

public void testMinSdk() {
    final MockPlatformTarget projectTarget = new MockPlatformTarget(14, 0);
    final EnumSet<IDevice.HardwareFeature> requiredFeatures = EnumSet.noneOf(IDevice.HardwareFeature.class);
    // cannot run if the API level of device is < API level required by minSdk
    LaunchCompatibility compatibility = LaunchCompatibility.canRunOnDevice(new AndroidVersion(8, null), projectTarget, requiredFeatures, null, createMockDevice(7, null));
    assertEquals(new LaunchCompatibility(ThreeState.NO, "minSdk(API 8) > deviceSdk(API 7)"), compatibility);
    // can run if the API level of device is >= API level required by minSdk
    compatibility = LaunchCompatibility.canRunOnDevice(new AndroidVersion(8, null), projectTarget, requiredFeatures, null, createMockDevice(8, null));
    assertEquals(new LaunchCompatibility(ThreeState.YES, null), compatibility);
    // cannot run if minSdk uses a code name that is not matched by the device
    compatibility = LaunchCompatibility.canRunOnDevice(new AndroidVersion(8, "P"), projectTarget, requiredFeatures, null, createMockDevice(9, null));
    assertEquals(new LaunchCompatibility(ThreeState.NO, "minSdk(API 8, P preview) != deviceSdk(API 9)"), compatibility);
}
Also used : MockPlatformTarget(com.android.sdklib.internal.androidTarget.MockPlatformTarget) IDevice(com.android.ddmlib.IDevice) AndroidVersion(com.android.sdklib.AndroidVersion)

Aggregations

AndroidVersion (com.android.sdklib.AndroidVersion)89 Test (org.junit.Test)21 NotNull (org.jetbrains.annotations.NotNull)14 IAndroidTarget (com.android.sdklib.IAndroidTarget)12 IDevice (com.android.ddmlib.IDevice)11 Nullable (org.jetbrains.annotations.Nullable)9 MockPlatformTarget (com.android.sdklib.internal.androidTarget.MockPlatformTarget)8 Module (com.intellij.openapi.module.Module)8 File (java.io.File)8 AndroidFacet (org.jetbrains.android.facet.AndroidFacet)8 AndroidPlatform (org.jetbrains.android.sdk.AndroidPlatform)8 DetailsTypes (com.android.sdklib.repository.meta.DetailsTypes)6 Project (com.intellij.openapi.project.Project)5 Abi (com.android.sdklib.devices.Abi)4 InstantRunGradleSupport (com.android.tools.idea.fd.gradle.InstantRunGradleSupport)4 AndroidModuleModel (com.android.tools.idea.gradle.project.model.AndroidModuleModel)4 OutputFile (com.android.build.OutputFile)3 TypeDetails (com.android.repository.impl.meta.TypeDetails)3 AvdInfo (com.android.sdklib.internal.avd.AvdInfo)3 ModelWizardDialog (com.android.tools.idea.wizard.model.ModelWizardDialog)3