use of com.android.tools.idea.gradle.project.sync.hyperlink.InstallPlatformHyperlink in project android by JetBrains.
the class SdksCleanupStep method reinstallMissingPlatforms.
private void reinstallMissingPlatforms(@NotNull Collection<Sdk> invalidAndroidSdks, @NotNull Project project) {
List<AndroidVersion> versionsToInstall = Lists.newArrayList();
List<String> missingPlatforms = Lists.newArrayList();
for (Sdk sdk : invalidAndroidSdks) {
AndroidSdkAdditionalData additionalData = myAndroidSdks.getAndroidSdkAdditionalData(sdk);
if (additionalData != null) {
String platform = additionalData.getBuildTargetHashString();
if (platform != null) {
missingPlatforms.add("'" + platform + "'");
AndroidVersion version = AndroidTargetHash.getPlatformVersion(platform);
if (version != null) {
versionsToInstall.add(version);
}
}
}
}
if (!versionsToInstall.isEmpty()) {
String text = "Missing Android platform(s) detected: " + Joiner.on(", ").join(missingPlatforms);
SyncMessage msg = new SyncMessage(SyncMessage.DEFAULT_GROUP, ERROR, text);
msg.add(new InstallPlatformHyperlink(versionsToInstall));
SyncMessages.getInstance(project).report(msg);
}
}
use of com.android.tools.idea.gradle.project.sync.hyperlink.InstallPlatformHyperlink in project android by JetBrains.
the class MissingPlatformErrorHandler method findAndAddQuickFixes.
private void findAndAddQuickFixes(@NotNull NotificationData notification, @NotNull Project project, @NotNull String text) {
String missingPlatform = getMissingPlatform(text);
if (missingPlatform == null) {
return;
}
String loadError = null;
List<NotificationHyperlink> hyperlinks = new ArrayList<>();
AndroidSdkHandler sdkHandler = null;
AndroidSdkData androidSdkData = AndroidSdks.getInstance().tryToChooseAndroidSdk();
if (androidSdkData != null) {
sdkHandler = androidSdkData.getSdkHandler();
}
if (sdkHandler != null) {
AndroidVersion version = AndroidTargetHash.getPlatformVersion(missingPlatform);
if (version != null) {
// Is the platform installed?
ProgressIndicator logger = new StudioLoggerProgressIndicator(getClass());
loadError = sdkHandler.getAndroidTargetManager(logger).getErrorForPackage(DetailsTypes.getPlatformPath(version));
hyperlinks.add(new InstallPlatformHyperlink(version));
}
}
if (hyperlinks.isEmpty()) {
// We are unable to install platform automatically.
List<AndroidFacet> facets = ProjectFacetManager.getInstance(project).getFacets(AndroidFacet.ID);
if (!facets.isEmpty()) {
// We can only open SDK manager if the project has an Android facet. Android facet has a reference to the Android SDK manager.
hyperlinks.add(new OpenAndroidSdkManagerHyperlink());
}
}
if (isNotEmpty(loadError)) {
text += "\nPossible cause: " + loadError;
}
SyncMessages.getInstance(project).updateNotification(notification, text, hyperlinks);
}
Aggregations