use of com.android.sdklib.repository.AndroidSdkHandler in project android by JetBrains.
the class LintIdeClient method getSdk.
@Nullable
@Override
public AndroidSdkHandler getSdk() {
if (sdk == null) {
Module module = getModule();
AndroidSdkHandler localSdk = getLocalSdk(module);
if (localSdk != null) {
sdk = localSdk;
} else {
for (Module m : ModuleManager.getInstance(myProject).getModules()) {
localSdk = getLocalSdk(m);
if (localSdk != null) {
sdk = localSdk;
break;
}
}
if (localSdk == null) {
sdk = super.getSdk();
}
}
}
return sdk;
}
use of com.android.sdklib.repository.AndroidSdkHandler in project android by JetBrains.
the class AndroidVersionsInfo method loadRemoteTargets.
private void loadRemoteTargets(@NotNull FormFactor myFormFactor, int minSdkLevel, @NotNull List<VersionItem> versionItemList, ItemsLoaded completedCallback) {
AndroidSdkHandler sdkHandler = AndroidSdks.getInstance().tryToChooseSdkHandler();
final Runnable runCallbacks = () -> {
if (completedCallback != null) {
completedCallback.onDataLoadedFinished(versionItemList);
}
};
RepoManager.RepoLoadedCallback onComplete = packages -> {
addPackages(myFormFactor, versionItemList, packages.getNewPkgs(), minSdkLevel);
addOfflineLevels(myFormFactor, versionItemList);
runCallbacks.run();
};
// We need to pick up addons that don't have a target created due to the base platform not being installed.
RepoManager.RepoLoadedCallback onLocalComplete = packages -> addPackages(myFormFactor, versionItemList, packages.getLocalPackages().values(), minSdkLevel);
Runnable onError = () -> ApplicationManager.getApplication().invokeLater(() -> {
addOfflineLevels(myFormFactor, versionItemList);
runCallbacks.run();
}, ModalityState.any());
StudioProgressRunner runner = new StudioProgressRunner(false, false, "Refreshing Targets", true, null);
sdkHandler.getSdkManager(REPO_LOG).load(RepoManager.DEFAULT_EXPIRATION_PERIOD_MS, ImmutableList.of(onLocalComplete), ImmutableList.of(onComplete), ImmutableList.of(onError), runner, new StudioDownloader(), StudioSettingsController.getInstance(), false);
}
use of com.android.sdklib.repository.AndroidSdkHandler in project android by JetBrains.
the class ConfigureAndroidProjectPath method putSdkDependentParams.
/**
* Populate the given state with a set of variables that depend on the user's installed SDK. This method should
* be called early in the initialization of a wizard or path.
* Variables:
* Build Tools Version: Used to populate the project level build.gradle with the correct Gradle plugin version number
* If the required build tools version is not installed, a request is added for installation
* SDK Home: The location of the installed SDK
*
* @param state the state store to populate with the values stored in the SDK
*/
public static void putSdkDependentParams(@NotNull ScopedStateStore state) {
final AndroidSdkHandler sdkHandler = AndroidSdks.getInstance().tryToChooseSdkHandler();
StudioLoggerProgressIndicator progress = new StudioLoggerProgressIndicator(ConfigureAndroidProjectPath.class);
BuildToolInfo buildTool = sdkHandler.getLatestBuildTool(progress, false);
Revision minimumRequiredBuildToolVersion = Revision.parseRevision(SdkConstants.MIN_BUILD_TOOLS_VERSION);
if (buildTool != null && buildTool.getRevision().compareTo(minimumRequiredBuildToolVersion) >= 0) {
state.put(WizardConstants.BUILD_TOOLS_VERSION_KEY, buildTool.getRevision().toString());
} else {
// We need to install a new build tools version
state.listPush(WizardConstants.INSTALL_REQUESTS_KEY, DetailsTypes.getBuildToolsPath(minimumRequiredBuildToolVersion));
state.put(WizardConstants.BUILD_TOOLS_VERSION_KEY, minimumRequiredBuildToolVersion.toString());
}
File location = sdkHandler.getLocation();
if (location != null) {
// Gradle expects a platform-neutral path
state.put(WizardConstants.SDK_DIR_KEY, FileUtil.toSystemIndependentName(location.getPath()));
}
}
use of com.android.sdklib.repository.AndroidSdkHandler in project android by JetBrains.
the class FirstRunWizard method init.
@Override
public void init() {
File initialSdkLocation = FirstRunWizardDefaults.getInitialSdkLocation(myMode);
ConsolidatedProgressStep progressStep = new FirstRunProgressStep();
myComponentsPath = new InstallComponentsPath(myMode, initialSdkLocation, progressStep, true);
if (myMode == FirstRunWizardMode.NEW_INSTALL) {
boolean sdkExists = false;
if (initialSdkLocation.isDirectory()) {
AndroidSdkHandler sdkHandler = AndroidSdkHandler.getInstance(initialSdkLocation);
ProgressIndicator progress = new StudioLoggerProgressIndicator(getClass());
sdkExists = ((AndroidSdkHandler) sdkHandler).getLocalPackage(SdkConstants.FD_TOOLS, progress) != null;
}
addPath(new SingleStepPath(new FirstRunWelcomeStep(sdkExists)));
}
if (myMode == FirstRunWizardMode.NEW_INSTALL) {
if (initialSdkLocation.getPath().isEmpty()) {
// We don't have a default path specified, have to do custom install.
myState.put(KEY_CUSTOM_INSTALL, true);
} else {
addPath(new SingleStepPath(new InstallationTypeWizardStep(KEY_CUSTOM_INSTALL)));
}
addPath(new SingleStepPath(new SelectThemeStep(KEY_CUSTOM_INSTALL)));
}
if (myMode == FirstRunWizardMode.MISSING_SDK) {
addPath(new SingleStepPath(new MissingSdkAlertStep()));
}
addPath(myComponentsPath);
if (SystemInfo.isLinux && myMode == FirstRunWizardMode.NEW_INSTALL) {
addPath(new SingleStepPath(new LinuxHaxmInfoStep()));
}
if (myMode != FirstRunWizardMode.INSTALL_HANDOFF) {
addPath(new SingleStepPath(new LicenseAgreementStep(getDisposable())));
}
addPath(new SingleStepPath(progressStep));
super.init();
}
use of com.android.sdklib.repository.AndroidSdkHandler 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