use of com.android.repository.api.RemotePackage 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.repository.api.RemotePackage in project android by JetBrains.
the class InstallComponentsPath method createComponentTree.
private ComponentTreeNode createComponentTree(@NotNull FirstRunWizardMode reason, @NotNull ScopedStateStore stateStore, boolean createAvd) {
List<ComponentTreeNode> components = Lists.newArrayList();
components.add(new AndroidSdk(stateStore, myInstallUpdates));
DynamicWizard wizard = getWizard();
ProgressWindow progressWindow = new ProgressWindow(false, false, null);
if (wizard != null) {
Disposer.register(wizard.getDisposable(), progressWindow);
}
com.android.repository.api.ProgressIndicator progress = new RepoProgressIndicatorAdapter(progressWindow);
RepoManager sdkManager = myLocalHandler.getSdkManager(new StudioLoggerProgressIndicator(getClass()));
sdkManager.loadSynchronously(RepoManager.DEFAULT_EXPIRATION_PERIOD_MS, progress, new StudioDownloader(progressWindow), StudioSettingsController.getInstance());
Map<String, RemotePackage> remotePackages = sdkManager.getPackages().getRemotePackages();
ComponentTreeNode platforms = Platform.createSubtree(stateStore, remotePackages, myInstallUpdates);
if (platforms != null) {
components.add(platforms);
}
if (Haxm.canRun() && reason == FirstRunWizardMode.NEW_INSTALL) {
Haxm.HaxmInstallationIntention haxmInstallationIntention = myInstallUpdates ? Haxm.HaxmInstallationIntention.INSTALL_WITH_UPDATES : Haxm.HaxmInstallationIntention.INSTALL_WITHOUT_UPDATES;
components.add(new Haxm(haxmInstallationIntention, stateStore, FirstRunWizard.KEY_CUSTOM_INSTALL));
}
if (createAvd) {
components.add(new AndroidVirtualDevice(stateStore, remotePackages, myInstallUpdates, myFileOp));
}
return new ComponentCategory("Root", "Root node that is not supposed to appear in the UI", components);
}
use of com.android.repository.api.RemotePackage in project android by JetBrains.
the class SystemImageListModel method getRemoteImages.
@Nullable
private static List<SystemImageDescription> getRemoteImages(@NotNull RepositoryPackages packages) {
List<SystemImageDescription> items = Lists.newArrayList();
Set<RemotePackage> infos = packages.getNewPkgs();
if (infos.isEmpty()) {
return null;
} else {
for (RemotePackage info : infos) {
if (SystemImageDescription.hasSystemImage(info)) {
SystemImageDescription image = new SystemImageDescription(info);
items.add(image);
}
}
}
return items;
}
use of com.android.repository.api.RemotePackage in project android by JetBrains.
the class RepositoryUrlManager method resolveDynamicCoordinateVersion.
@Nullable
@VisibleForTesting
String resolveDynamicCoordinateVersion(@NotNull GradleCoordinate coordinate, @Nullable Project project, @NotNull AndroidSdkHandler sdkHandler) {
if (coordinate.getGroupId() == null || coordinate.getArtifactId() == null) {
return null;
}
String filter = coordinate.getRevision();
if (!filter.endsWith("+")) {
// Already resolved. That was easy.
return filter;
}
filter = filter.substring(0, filter.length() - 1);
File sdkLocation = sdkHandler.getLocation();
if (sdkLocation != null) {
// If this coordinate points to an artifact in one of our repositories, mark it will a comment if they don't
// have that repository available.
String libraryCoordinate = getLibraryRevision(coordinate.getGroupId(), coordinate.getArtifactId(), filter, false, sdkLocation, sdkHandler.getFileOp());
if (libraryCoordinate != null) {
return libraryCoordinate;
}
// If that didn't yield any matches, try again, this time allowing preview platforms.
// This is necessary if the artifact filter includes enough of a version where there are
// only preview matches.
libraryCoordinate = getLibraryRevision(coordinate.getGroupId(), coordinate.getArtifactId(), filter, true, sdkLocation, sdkHandler.getFileOp());
if (libraryCoordinate != null) {
return libraryCoordinate;
}
}
// Regular Gradle dependency? Look in Gradle cache
GradleVersion versionFound = GradleLocalCache.getInstance().findLatestArtifactVersion(coordinate, project, filter);
if (versionFound != null) {
return versionFound.toString();
}
// Maybe it's available for download as an SDK component
RemotePackage sdkPackage = SdkMavenRepository.findLatestRemoteVersion(coordinate, sdkHandler, new StudioLoggerProgressIndicator(getClass()));
if (sdkPackage != null) {
GradleCoordinate found = SdkMavenRepository.getCoordinateFromSdkPath(sdkPackage.getPath());
if (found != null) {
return found.getRevision();
}
}
// Perform network lookup to resolve current best version, if possible
if (project != null) {
LintClient client = new LintIdeClient(project);
Revision latest = GradleDetector.getLatestVersionFromRemoteRepo(client, coordinate, coordinate.isPreview());
if (latest != null) {
String version = latest.toShortString();
if (version.startsWith(filter)) {
return version;
}
}
}
return null;
}
use of com.android.repository.api.RemotePackage in project android by JetBrains.
the class InstallCMakeHyperlink method execute.
@Override
protected void execute(@NotNull Project project) {
// We need to statically fetch the SDK handler each time because the location might change.
// TODO: remove the need for doing this each time.
AndroidSdkHandler sdkHandler = AndroidSdks.getInstance().tryToChooseSdkHandler();
StudioLoggerProgressIndicator progressIndicator = new StudioLoggerProgressIndicator(getClass());
RepoManager sdkManager = sdkHandler.getSdkManager(progressIndicator);
StudioProgressRunner progressRunner = new StudioProgressRunner(false, /* backgroundable */
false, /* cancellable */
"Loading Remote SDK", true, /* in UI thread */
project);
RepoManager.RepoLoadedCallback onComplete = packages -> {
Collection<RemotePackage> cmakePackages = packages.getRemotePackagesForPrefix(FD_CMAKE);
if (!cmakePackages.isEmpty()) {
RemotePackage cmakePackage;
if (cmakePackages.size() == 1) {
cmakePackage = getFirstItem(cmakePackages);
} else {
cmakePackage = sdkHandler.getLatestRemotePackageForPrefix(FD_CMAKE, false, progressIndicator);
}
if (cmakePackage != null) {
ModelWizardDialog dialog = createDialogForPaths(project, ImmutableList.of(cmakePackage.getPath()));
if (dialog != null && dialog.showAndGet()) {
GradleSyncInvoker.getInstance().requestProjectSyncAndSourceGeneration(project, null);
}
return;
}
notifyCMakePackageNotFound(project);
}
};
Runnable onError = () -> notifyCMakePackageNotFound(project);
sdkManager.load(DEFAULT_EXPIRATION_PERIOD_MS, null, ImmutableList.of(onComplete), ImmutableList.of(onError), progressRunner, new StudioDownloader(), StudioSettingsController.getInstance(), false);
}
Aggregations