use of com.android.sdklib.AndroidVersion in project android by JetBrains.
the class DeveloperServiceCreator method createContext.
@NotNull
private static ServiceContext createContext(@NotNull Module module) {
String buildSystemId = getBuildSystemOperations(module.getProject()).getBuildSystemId();
ServiceContext context = new ServiceContext(buildSystemId);
String packageName = MergedManifest.get(module).getPackage();
if (packageName != null) {
context.putValue("packageName", new StringValueProperty(packageName));
}
AndroidPlatform platform = AndroidPlatform.getInstance(module);
if (platform != null) {
// Add the compileSdkVersion (or buildApiVersion) such that compatible dependencies are chosen
AndroidVersion version = platform.getApiVersion();
context.putValue(ATTR_BUILD_API, new IntValueProperty(version.getFeatureLevel()));
context.putValue(ATTR_BUILD_API_STRING, new StringValueProperty(getBuildApiString(version)));
}
return context;
}
use of com.android.sdklib.AndroidVersion in project android by JetBrains.
the class AndroidSdkUtils method getTargetLabel.
/**
* For a given target, returns a brief user-facing string that describes the platform, including the API level, platform version number,
* and codename. Does the right thing with pre-release platforms.
*/
@NotNull
public static String getTargetLabel(@NotNull IAndroidTarget target) {
if (!target.isPlatform()) {
return String.format("%1$s (API %2$s)", target.getFullName(), target.getVersion().getApiString());
}
AndroidVersion version = target.getVersion();
if (version.isPreview()) {
return String.format("API %d+: %s", target.getVersion().getApiLevel(), target.getName());
}
String name = SdkVersionInfo.getAndroidName(target.getVersion().getApiLevel());
if (isNotEmpty(name)) {
return name;
}
//$NON-NLS-1$
String release = target.getProperty("ro.build.version.release");
if (release != null) {
return String.format("API %1$d: Android %2$s", version.getApiLevel(), release);
}
return String.format("API %1$d", version.getApiLevel());
}
use of com.android.sdklib.AndroidVersion in project android by JetBrains.
the class AndroidSdkType method setupSdkPaths.
@Override
public boolean setupSdkPaths(@NotNull Sdk sdk, @NotNull SdkModel sdkModel) {
final List<String> javaSdks = Lists.newArrayList();
final Sdk[] sdks = sdkModel.getSdks();
for (Sdk jdk : sdks) {
if (Jdks.getInstance().isApplicableJdk(jdk)) {
javaSdks.add(jdk.getName());
}
}
if (javaSdks.isEmpty()) {
Messages.showErrorDialog(AndroidBundle.message("no.jdk.for.android.found.error"), "No Java SDK Found");
return false;
}
MessageBuildingSdkLog log = new MessageBuildingSdkLog();
AndroidSdkData sdkData = getSdkData(sdk);
if (sdkData == null) {
String errorMessage = !log.getErrorMessage().isEmpty() ? log.getErrorMessage() : AndroidBundle.message("cannot.parse.sdk.error");
Messages.showErrorDialog(errorMessage, "SDK Parsing Error");
return false;
}
IAndroidTarget[] targets = sdkData.getTargets();
if (targets.length == 0) {
if (Messages.showOkCancelDialog(AndroidBundle.message("no.android.targets.error"), CommonBundle.getErrorTitle(), "Open SDK Manager", Messages.CANCEL_BUTTON, Messages.getErrorIcon()) == Messages.OK) {
ActionManager.getInstance().getAction("Android.RunAndroidSdkManager").actionPerformed(null);
}
return false;
}
String[] targetNames = new String[targets.length];
String newestPlatform = null;
AndroidVersion version = null;
for (int i = 0; i < targets.length; i++) {
IAndroidTarget target = targets[i];
String targetName = getTargetPresentableName(target);
targetNames[i] = targetName;
if (target.isPlatform() && (version == null || target.getVersion().compareTo(version) > 0)) {
newestPlatform = targetName;
version = target.getVersion();
}
}
AndroidNewSdkDialog dialog = new AndroidNewSdkDialog(null, javaSdks, javaSdks.get(0), Arrays.asList(targetNames), newestPlatform != null ? newestPlatform : targetNames[0]);
if (!dialog.showAndGet()) {
return false;
}
String name = javaSdks.get(dialog.getSelectedJavaSdkIndex());
Sdk jdk = sdkModel.findSdk(name);
IAndroidTarget target = targets[dialog.getSelectedTargetIndex()];
String sdkName = AndroidSdks.getInstance().chooseNameForNewLibrary(target);
AndroidSdks.getInstance().setUpSdk(sdk, target, sdkName, Arrays.asList(sdks), jdk, true);
return true;
}
use of com.android.sdklib.AndroidVersion in project android by JetBrains.
the class SystemImagePreview method setImage.
/**
* Set the image to display.
*/
public void setImage(@Nullable SystemImageDescription image) {
myImageDescription = image;
myHaxmAlert.setSystemImageDescription(image);
((CardLayout) myRootPanel.getLayout()).show(myRootPanel, NO_IMAGE_CONTENT);
if (image != null) {
((CardLayout) myRootPanel.getLayout()).show(myRootPanel, MAIN_CONTENT);
AndroidVersion version = image.getVersion();
if (version == null) {
return;
}
int apiLevel = version.getApiLevel();
myApiLevelListener.setApiLevel(apiLevel);
String codeName = SdkVersionInfo.getCodeName(myImageDescription.getVersion().getApiLevel());
if (codeName != null) {
myReleaseName.setText(codeName);
}
Icon icon = getIcon(codeName);
if (icon != null) {
myReleaseIcon.setIcon(icon);
}
myApiLevel.setText(image.getVersion().getApiString());
myAndroidVersion.setVisible(!image.getVersion().isPreview());
myAndroidVersion.setText(SdkVersionInfo.getVersionString(apiLevel));
String vendorName;
IdDisplay tag = myImageDescription.getTag();
if (tag.getId().equals("android-wear") || tag.getId().equals("android-tv")) {
vendorName = "Android";
} else {
vendorName = myImageDescription.getVendor();
}
myVendor.setText("<html>" + vendorName + "</html>");
myAbi.setText(myImageDescription.getAbiType());
}
}
use of com.android.sdklib.AndroidVersion in project android by JetBrains.
the class AndroidVersionsInfo method getInstallRequestPaths.
@NotNull
public Collection<String> getInstallRequestPaths(@NotNull VersionItem... versionItems) {
Set<String> res = Sets.newHashSet();
for (VersionItem versionItem : versionItems) {
AndroidVersion androidVersion = versionItem.myAndroidVersion;
String platformPath = DetailsTypes.getPlatformPath(androidVersion);
// Check to see if this is installed. If not, request that we install it
if (versionItem.myAddon != null) {
// The user selected a non platform SDK (e.g. for Google Glass). Let us install it:
res.add(versionItem.myAddon.getPath());
// We also need the platform if not already installed:
AndroidTargetManager targetManager = AndroidSdks.getInstance().tryToChooseSdkHandler().getAndroidTargetManager(REPO_LOG);
if (targetManager.getTargetFromHashString(AndroidTargetHash.getPlatformHashString(androidVersion), REPO_LOG) == null) {
res.add(platformPath);
}
} else {
// unlikely, so this logic can wait for a followup CL.
if (myHighestInstalledApiTarget == null || (androidVersion.getApiLevel() > myHighestInstalledApiTarget.getVersion().getApiLevel() && !myInstalledVersions.contains(androidVersion))) {
// Let us install the HIGHEST_KNOWN_STABLE_API.
res.add(DetailsTypes.getPlatformPath(new AndroidVersion(SdkVersionInfo.HIGHEST_KNOWN_STABLE_API, null)));
}
}
}
return res;
}
Aggregations