use of com.android.tools.idea.gradle.project.sync.hyperlink.OpenAndroidSdkManagerHyperlink in project android by JetBrains.
the class MissingPlatformsSetupStep method setUpProject.
@Override
public void setUpProject(@NotNull Project project, @Nullable ProgressIndicator indicator) {
SyncMessages syncMessages = SyncMessages.getInstance(project);
int sdkErrorCount = syncMessages.getMessageCount(SDK_SETUP_ISSUES);
if (sdkErrorCount > 0) {
// If we have errors due to platforms not being installed, we add an extra message that prompts user to open Android SDK manager and
// install any missing platforms.
String text = "Open Android SDK Manager and install all missing platforms.";
SyncMessage hint = new SyncMessage(SDK_SETUP_ISSUES, INFO, NonNavigatable.INSTANCE, text);
hint.add(new OpenAndroidSdkManagerHyperlink());
syncMessages.report(hint);
}
}
use of com.android.tools.idea.gradle.project.sync.hyperlink.OpenAndroidSdkManagerHyperlink in project android by JetBrains.
the class MissingAndroidSupportRepoErrorHandler method getQuickFixHyperlinks.
@Override
@NotNull
protected List<NotificationHyperlink> getQuickFixHyperlinks(@NotNull NotificationData notification, @NotNull Project project, @NotNull String text) {
List<NotificationHyperlink> hyperlinks = new ArrayList<>();
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());
}
return hyperlinks;
}
use of com.android.tools.idea.gradle.project.sync.hyperlink.OpenAndroidSdkManagerHyperlink in project android by JetBrains.
the class ObjectStreamErrorHandler method findAndAddQuickFixes.
private static void findAndAddQuickFixes(@NotNull NotificationData notification, @NotNull Project project, @NotNull String text) {
List<NotificationHyperlink> hyperlinks = new ArrayList<>();
NotificationHyperlink buildProjectHyperlink = new BuildProjectHyperlink();
NotificationHyperlink openAndroidSdkManagerHyperlink = new OpenAndroidSdkManagerHyperlink();
text += "Please try one of the following:<ul>" + "<li>" + buildProjectHyperlink.toHtml() + " to obtain the cause of the error</li>" + "<li>" + openAndroidSdkManagerHyperlink.toHtml() + " to check if there are any missing components</li></ul>";
hyperlinks.add(buildProjectHyperlink);
hyperlinks.add(openAndroidSdkManagerHyperlink);
notification.setTitle(SyncMessage.DEFAULT_GROUP);
notification.setMessage(text);
notification.setNotificationCategory(NotificationCategory.convert(DEFAULT_NOTIFICATION_TYPE));
SyncMessages.getInstance(project).addNotificationListener(notification, hyperlinks);
}
use of com.android.tools.idea.gradle.project.sync.hyperlink.OpenAndroidSdkManagerHyperlink in project android by JetBrains.
the class AndroidFacetImporterBase method reportCannotFindAndroidPlatformError.
private static void reportCannotFindAndroidPlatformError(String moduleName, @Nullable String apiLevel, Project project) {
final OpenAndroidSdkManagerHyperlink hyperlink = new OpenAndroidSdkManagerHyperlink();
AndroidUtils.reportImportErrorToEventLog("Cannot find appropriate Android platform" + (apiLevel != null ? " for API level " + apiLevel : "") + ". " + hyperlink.toHtml(), moduleName, project, new CustomNotificationListener(project, hyperlink));
}
use of com.android.tools.idea.gradle.project.sync.hyperlink.OpenAndroidSdkManagerHyperlink 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