use of com.android.tools.idea.gradle.project.sync.messages.SyncMessage in project android by JetBrains.
the class UnresolvedDependenciesReporter method report.
private void report(@NotNull String dependency, @NotNull Module module, @Nullable VirtualFile buildFile) {
String group = "Unresolved Android dependencies";
GradleCoordinate coordinate = GradleCoordinate.parseCoordinateString(dependency);
RepoPackage constraintPackage = null;
if (coordinate != null) {
ProgressIndicator indicator = new StudioLoggerProgressIndicator(getClass());
reloadRemoteSdkWithModalProgress();
Collection<RemotePackage> remotePackages = getRemotePackages(indicator);
constraintPackage = findBestPackageMatching(coordinate, remotePackages);
}
List<NotificationHyperlink> quickFixes = new ArrayList<>();
if (dependency.startsWith("com.android.support.constraint:constraint-layout:") && !canGetConstraintLayoutFromSdkManager(module)) {
quickFixes.add(new FixAndroidGradlePluginVersionHyperlink());
} else if (constraintPackage != null) {
quickFixes.add(new InstallArtifactHyperlink(constraintPackage.getPath()));
} else if (dependency.startsWith("com.android.support")) {
quickFixes.add(new InstallRepositoryHyperlink(ANDROID));
} else if (dependency.startsWith("com.google.android")) {
quickFixes.add(new InstallRepositoryHyperlink(GOOGLE));
} else {
group = "Unresolved dependencies";
Project project = module.getProject();
if (isOfflineBuildModeEnabled(project)) {
quickFixes.add(new DisableOfflineModeHyperlink());
}
}
String text = "Failed to resolve: " + dependency;
SyncMessage message;
if (buildFile != null) {
PositionInFile position = findDependencyPosition(dependency, buildFile);
message = new SyncMessage(module.getProject(), group, ERROR, position, text);
String hyperlinkText = position.line > -1 ? "Show in File" : "Open File";
quickFixes.add(new OpenFileHyperlink(buildFile.getPath(), hyperlinkText, position.line, position.column));
} else {
message = new SyncMessage(group, ERROR, NonNavigatable.INSTANCE, text);
}
if (IdeInfo.getInstance().isAndroidStudio()) {
if (coordinate != null) {
quickFixes.add(new ShowDependencyInProjectStructureHyperlink(module, coordinate));
}
}
message.add(quickFixes);
getSyncMessages(module).report(message);
}
use of com.android.tools.idea.gradle.project.sync.messages.SyncMessage in project android by JetBrains.
the class JdkPreSyncCheck method doCheckCanSync.
@Override
@NotNull
PreSyncCheckResult doCheckCanSync(@NotNull Project project) {
Sdk jdk = IdeSdks.getInstance().getJdk();
if (!isValidJdk(jdk)) {
String msg = "Please use JDK 8 or newer.";
SyncMessage message = new SyncMessage("Project sync error", MessageType.ERROR, msg);
List<NotificationHyperlink> quickFixes = Jdks.getInstance().getWrongJdkQuickFixes(project);
message.add(quickFixes);
SyncMessages.getInstance(project).report(message);
return failure(msg);
}
return SUCCESS;
}
use of com.android.tools.idea.gradle.project.sync.messages.SyncMessage in project android by JetBrains.
the class JavaModuleSetup method setUpModule.
public void setUpModule(@NotNull Module module, @NotNull IdeModifiableModelsProvider ideModelsProvider, @NotNull JavaModuleModel javaModuleModel, @Nullable SyncAction.ModuleModels models, @Nullable ProgressIndicator indicator) {
if (javaModuleModel.isAndroidModuleWithoutVariants()) {
// See https://code.google.com/p/android/issues/detail?id=170722
SyncMessages messages = SyncMessages.getInstance(module.getProject());
String[] text = { String.format("The module '%1$s' is an Android project without build variants, and cannot be built.", module.getName()), "Please fix the module's configuration in the build.gradle file and sync the project again." };
messages.report(new SyncMessage(PROJECT_STRUCTURE_ISSUES, ERROR, text));
cleanUpAndroidModuleWithoutVariants(module, ideModelsProvider);
// happen due to a project configuration error and there is a lot of module configuration missing, there is no point on even trying.
return;
}
for (JavaModuleSetupStep step : mySetupSteps) {
if (indicator != null) {
step.displayDescription(module, indicator);
}
step.setUpModule(module, ideModelsProvider, javaModuleModel, models, indicator);
}
}
use of com.android.tools.idea.gradle.project.sync.messages.SyncMessage in project android by JetBrains.
the class BuildToolsTooLowReporter method report.
@Override
void report(@NotNull SyncIssue syncIssue, @NotNull Module module, @Nullable VirtualFile buildFile) {
String minimumVersion = syncIssue.getData();
assert minimumVersion != null;
SyncMessage message = new SyncMessage(SyncMessage.DEFAULT_GROUP, ERROR, syncIssue.getMessage());
List<NotificationHyperlink> quickFixes = myErrorHandler.getQuickFixHyperlinks(minimumVersion, module.getProject(), module);
message.add(quickFixes);
getSyncMessages(module).report(message);
}
use of com.android.tools.idea.gradle.project.sync.messages.SyncMessage in project android by JetBrains.
the class JdkModuleSetupStep method reportWrongJdkError.
@NotNull
private SyncMessage reportWrongJdkError(@NotNull Project project, @NotNull String text, @NotNull VirtualFile buildFile) {
int line = -1;
int column = -1;
Document document = FileDocumentManager.getInstance().getDocument(buildFile);
if (document != null) {
int offset = myCompileSdkVersionFinder.findOffsetIn(document.getText());
if (offset > -1) {
line = document.getLineNumber(offset);
if (line > -1) {
int lineStartOffset = document.getLineStartOffset(line);
column = offset - lineStartOffset;
}
}
}
PositionInFile position = new PositionInFile(buildFile, line, column);
SyncMessage msg = new SyncMessage(project, PROJECT_CONFIGURATION_SYNC_MESSAGE_GROUP, ERROR, position, text);
List<NotificationHyperlink> quickFixes = Lists.newArrayList(myJdks.getWrongJdkQuickFixes(project));
quickFixes.add(new OpenFileHyperlink(buildFile.getPath(), "Open build.gradle File", line, column));
msg.add(quickFixes);
return msg;
}
Aggregations