use of com.android.sdklib.IAndroidTarget in project android by JetBrains.
the class IdeSdksTest method assertOneSdkPerAvailableTarget.
private void assertOneSdkPerAvailableTarget(@NotNull List<Sdk> sdks) {
List<IAndroidTarget> platformTargets = Lists.newArrayList();
AndroidSdkData sdkData = AndroidSdkData.getSdkData(myAndroidSdkPath);
assertNotNull(sdkData);
for (IAndroidTarget target : sdkData.getTargets()) {
if (target.isPlatform()) {
platformTargets.add(target);
}
}
assertEquals(platformTargets.size(), sdks.size());
for (Sdk sdk : sdks) {
AndroidPlatform androidPlatform = AndroidPlatform.getInstance(sdk);
assertNotNull(androidPlatform);
IAndroidTarget target = androidPlatform.getTarget();
platformTargets.remove(target);
}
assertEquals(0, platformTargets.size());
}
use of com.android.sdklib.IAndroidTarget in project android by JetBrains.
the class VaryingConfiguration method getTarget.
@Override
@Nullable
public IAndroidTarget getTarget() {
if (isOverridingTarget()) {
return super.getTarget();
}
IAndroidTarget target = myParent.getTarget();
if (isAlternatingTarget() && target != null) {
ConfigurationManager manager = getConfigurationManager();
IAndroidTarget[] targets = manager.getTargets();
if (targets.length > 0) {
// Pick a different target: if you're showing the most recent render target,
// then pick the lowest supported target, and vice versa
IAndroidTarget mostRecent = manager.getHighestApiTarget();
if (target.equals(mostRecent)) {
// Find oldest supported
AndroidModuleInfo info = AndroidModuleInfo.get(manager.getModule());
if (info != null) {
int minSdkVersion = info.getMinSdkVersion().getFeatureLevel();
for (IAndroidTarget t : targets) {
if (t.getVersion().getFeatureLevel() >= minSdkVersion && ConfigurationManager.isLayoutLibTarget(t)) {
target = t;
break;
}
}
}
} else {
target = mostRecent;
}
}
}
return target;
}
use of com.android.sdklib.IAndroidTarget in project android by JetBrains.
the class SdksCleanupStep method shouldRemoveAnnotationsJar.
/*
* Indicates whether annotations.jar should be removed from the given SDK (if it is an Android SDK.)
* There are 2 issues:
* 1. annotations.jar is not needed for API level 16 and above. The annotations are already included in android.jar. Until recently, the
* IDE added annotations.jar to the IDEA Android SDK definition unconditionally.
* 2. Because annotations.jar is in the classpath, the IDE locks the file on Windows making automatic updates of SDK Tools fail. The
* update not only fails, it corrupts the 'tools' folder in the SDK.
* From now on, creating IDEA Android SDKs will not include annotations.jar if API level is 16 or above, but we still need to remove
* this jar from existing IDEA Android SDKs.
*/
private boolean shouldRemoveAnnotationsJar(@NotNull Sdk sdk) {
if (myAndroidSdks.isAndroidSdk(sdk)) {
AndroidSdkAdditionalData additionalData = myAndroidSdks.getAndroidSdkAdditionalData(sdk);
AndroidSdkData sdkData = AndroidSdkData.getSdkData(sdk);
boolean needsAnnotationsJar = false;
if (additionalData != null && sdkData != null) {
IAndroidTarget target = additionalData.getBuildTarget(sdkData);
if (target != null) {
needsAnnotationsJar = myAndroidSdks.needsAnnotationsJarInClasspath(target);
}
}
for (VirtualFile library : sdk.getRootProvider().getFiles(CLASSES)) {
// annotations.jar and res folder.
if (library.getName().equals(FN_ANNOTATIONS_JAR) && library.exists() && !needsAnnotationsJar) {
return true;
}
}
}
return false;
}
use of com.android.sdklib.IAndroidTarget in project android by JetBrains.
the class ResolutionUtils method getFolderConfiguration.
/**
* Gets the {@link FolderConfiguration} of a ResourceValue
* e.g. if we resolve a drawable using a mdpi configuration, yet that drawable only exists inside xhdpi, this method will return xhdpi
* @param configuration the FolderConfiguration that was used for resolving the ResourceValue
* @return the FolderConfiguration of the ResourceValue
*/
@NotNull
public static FolderConfiguration getFolderConfiguration(@NotNull AndroidFacet facet, @NotNull ResourceValue resolvedValue, @NotNull FolderConfiguration configuration) {
List<? extends Configurable> configurables;
if (resolvedValue.isFramework()) {
ConfigurationManager configurationManager = facet.getConfigurationManager();
// same as getHighestApiTarget();
IAndroidTarget target = configurationManager.getDefaultTarget();
assert target != null;
ResourceRepository resourceRepository = configurationManager.getResolverCache().getFrameworkResources(configuration, target);
assert resourceRepository != null;
ResourceItem resourceItem = resourceRepository.getResourceItem(resolvedValue.getResourceType(), resolvedValue.getName());
configurables = resourceItem.getSourceFileList();
} else {
AppResourceRepository appResourceRepository = facet.getAppResources(true);
configurables = appResourceRepository.getResourceItem(resolvedValue.getResourceType(), resolvedValue.getName());
}
Configurable configurable = configuration.findMatchingConfigurable(configurables);
assert configurable != null;
return configurable.getConfiguration();
}
use of com.android.sdklib.IAndroidTarget in project android by JetBrains.
the class GradleSpecificInitializer method checkAndSetSources.
private static void checkAndSetSources(@NotNull Sdk sdk) {
VirtualFile[] storedSources = sdk.getRootProvider().getFiles(OrderRootType.SOURCES);
if (storedSources.length > 0) {
return;
}
AndroidPlatform platform = AndroidPlatform.getInstance(sdk);
if (platform != null) {
SdkModificator sdkModificator = sdk.getSdkModificator();
IAndroidTarget target = platform.getTarget();
AndroidSdks.getInstance().findAndSetPlatformSources(target, sdkModificator);
sdkModificator.commitChanges();
}
}
Aggregations