use of com.android.sdklib.repository.AndroidSdkHandler in project android by JetBrains.
the class StudioSdkUtil method reloadRemoteSdkWithModalProgress.
/**
* Convenience method to reload the local and remote SDK, showing a modal, non-cancellable progress window.
*/
public static void reloadRemoteSdkWithModalProgress() {
final AndroidSdkHandler sdkHandler = AndroidSdks.getInstance().tryToChooseSdkHandler();
StudioProgressRunner runner = new StudioProgressRunner(true, false, "Refreshing SDK", false, null);
StudioLoggerProgressIndicator progress = new StudioLoggerProgressIndicator(StudioSdkUtil.class);
RepoManager sdkManager = sdkHandler.getSdkManager(progress);
sdkManager.load(RepoManager.DEFAULT_EXPIRATION_PERIOD_MS, null, null, null, runner, new StudioDownloader(null), StudioSettingsController.getInstance(), true);
}
use of com.android.sdklib.repository.AndroidSdkHandler in project android by JetBrains.
the class HaxmWizard method doCancelAction.
@Override
public void doCancelAction() {
if (myHaxmPath.canPerformFinishingActions()) {
doFinishAction();
return;
}
// Have to ensure the SDK package is removed
if (!myInvokedToUninstall) {
try {
AndroidSdkHandler sdkHandler = AndroidSdks.getInstance().tryToChooseSdkHandler();
ComponentInstaller componentInstaller = new ComponentInstaller(sdkHandler);
ProgressIndicator progress = new StudioLoggerProgressIndicator(getClass());
sdkHandler.getSdkManager(progress).reloadLocalIfNeeded(progress);
componentInstaller.ensureSdkPackagesUninstalled(myHaxmPath.myHaxm.getRequiredSdkPackages(), progress);
} catch (Exception e) {
Messages.showErrorDialog(SDK_PACKAGE_CLEANUP_FAILED, "Cleanup Error");
LOG.warn("Failed to make sure HAXM SDK package is uninstalled after HAXM wizard was cancelled", e);
}
}
super.doCancelAction();
}
use of com.android.sdklib.repository.AndroidSdkHandler in project android by JetBrains.
the class SdkMerger method compareSdks.
@NotNull
private static Collection<MergeablePackage> compareSdks(@NotNull File srcDir, @NotNull File destDir, @Nullable ProgressIndicator progress) {
com.android.repository.api.ProgressIndicator repoProgress = getRepoProgress(progress);
Collection<MergeablePackage> results = Lists.newArrayList();
AndroidSdkHandler srcHandler = AndroidSdkHandler.getInstance(srcDir);
AndroidSdkHandler destHandler = AndroidSdkHandler.getInstance(destDir);
Map<String, ? extends LocalPackage> srcPackages = srcHandler.getSdkManager(repoProgress).getPackages().getLocalPackages();
Map<String, ? extends LocalPackage> destPackages = destHandler.getSdkManager(repoProgress).getPackages().getLocalPackages();
for (LocalPackage srcPkg : srcPackages.values()) {
LocalPackage destPkg = destPackages.get(srcPkg.getPath());
if (destPkg != null) {
if (srcPkg.getVersion().compareTo(destPkg.getVersion()) > 0) {
// Package exists in destination but is old; replace it.
results.add(new MergeablePackage(srcPkg, destPkg, destDir));
}
} else {
// Package doesn't exist in destination; copy it over.
results.add(new MergeablePackage(srcPkg, null, destDir));
}
}
return results;
}
use of com.android.sdklib.repository.AndroidSdkHandler in project android by JetBrains.
the class AaptInvoker method getPathToAapt.
/**
* @return the path to aapt from the latest version of build tools that is installed, null if there are no build tools
*/
@Nullable
private static Path getPathToAapt() {
AndroidSdkHandler sdkHandler = AndroidSdks.getInstance().tryToChooseSdkHandler();
BuildToolInfo latestBuildTool = sdkHandler.getLatestBuildTool(new StudioLoggerProgressIndicator(AaptInvoker.class), true);
if (latestBuildTool == null) {
return null;
}
return latestBuildTool.getLocation().toPath().resolve(SdkConstants.FN_AAPT);
}
use of com.android.sdklib.repository.AndroidSdkHandler in project android by JetBrains.
the class NewModuleWizardState method putSdkDependentParams.
public void putSdkDependentParams() {
final AndroidSdkHandler sdkHandler = AndroidSdks.getInstance().tryToChooseSdkHandler();
BuildToolInfo buildTool = sdkHandler.getLatestBuildTool(new StudioLoggerProgressIndicator(getClass()), false);
if (buildTool != null) {
// If buildTool is null, the template will use buildApi instead, which might be good enough.
put(ATTR_BUILD_TOOLS_VERSION, buildTool.getRevision().toString());
}
File location = sdkHandler.getLocation();
if (location != null) {
// Gradle expects a platform-neutral path
put(ATTR_SDK_DIR, FileUtil.toSystemIndependentName(location.getPath()));
}
}
Aggregations