本文整理汇总了Java中org.jetbrains.android.sdk.AndroidSdkUtils.tryToChooseAndroidSdk方法的典型用法代码示例。如果您正苦于以下问题:Java AndroidSdkUtils.tryToChooseAndroidSdk方法的具体用法?Java AndroidSdkUtils.tryToChooseAndroidSdk怎么用?Java AndroidSdkUtils.tryToChooseAndroidSdk使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jetbrains.android.sdk.AndroidSdkUtils
的用法示例。
在下文中一共展示了AndroidSdkUtils.tryToChooseAndroidSdk方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testGradlePlus
import org.jetbrains.android.sdk.AndroidSdkUtils; //导入方法依赖的package包/类
public void testGradlePlus() throws Exception {
// Needs a valid SDK; can't use the mock one in the test data.
AndroidSdkData prevSdkData = AndroidSdkUtils.tryToChooseAndroidSdk();
if (prevSdkData == null) {
String recentSdkPath = AndroidTestBase.getRecentSdkPath();
String platformDir = AndroidTestBase.getRecentPlatformDir();
if (recentSdkPath == null || platformDir == null) {
System.out.println("Not running " + this.getClass() + "#" + getName() + ": Needs SDK with Support Repo installed");
return;
}
Sdk androidSdk = createAndroidSdk(recentSdkPath, platformDir);
AndroidPlatform androidPlatform = AndroidPlatform.getInstance(androidSdk);
assertNotNull(androidPlatform);
// Put default platforms in the list before non-default ones so they'll be looked at first.
AndroidSdkUtils.setSdkData(androidPlatform.getSdkData());
}
// NOTE: The android support repository must be installed in the SDK used by the test!
doTestWithFix(new AndroidLintInspectionToolProvider.AndroidLintGradleDynamicVersionInspection(),
"Replace with specific version", "build.gradle", "gradle");
AndroidSdkUtils.setSdkData(prevSdkData);
}
示例2: testJdk5
import org.jetbrains.android.sdk.AndroidSdkUtils; //导入方法依赖的package包/类
public void testJdk5() throws Exception {
if (DISABLED) {
return;
}
AndroidSdkData sdkData = AndroidSdkUtils.tryToChooseAndroidSdk();
assertNotNull(sdkData);
IAndroidTarget[] targets = sdkData.getTargets();
IAndroidTarget target = targets[targets.length - 1];
Map<String,Object> overrides = Maps.newHashMap();
overrides.put(ATTR_JAVA_VERSION, "1.5");
NewProjectWizardState state = createNewProjectState(true, sdkData);
// TODO: Allow null activity state!
File activity = findTemplate("activities", "BlankActivity");
TemplateWizardState activityState = state.getActivityTemplateState();
assertNotNull(activity);
activityState.setTemplateLocation(activity);
checkApiTarget(8, 18, target, state, "Test15", null, overrides);
}
示例3: performFinishingActions
import org.jetbrains.android.sdk.AndroidSdkUtils; //导入方法依赖的package包/类
@Override
public void performFinishingActions() {
List<IPkgDesc> skipped = myState.get(SKIPPED_INSTALL_REQUESTS_KEY);
if (skipped != null && !skipped.isEmpty()) {
StringBuilder warningBuilder = new StringBuilder("The following packages were not installed.\n\n Would you like to exit ");
warningBuilder.append(ApplicationNamesInfo.getInstance().getFullProductName());
warningBuilder.append(" and install the following packages using the standalone SDK manager?");
for (IPkgDesc problemPkg : skipped) {
warningBuilder.append("\n");
warningBuilder.append(problemPkg.getListDescription());
}
String restartOption = String.format("Exit %s and launch SDK Manager", ApplicationNamesInfo.getInstance().getProductName());
int result = Messages.showDialog(getProject(), warningBuilder.toString(), "Warning", new String[]{restartOption, "Skip installation"},
0, AllIcons.General.Warning);
if (result == 0) {
startSdkManagerAndExit();
}
}
// We've already installed things, so clearly there's an SDK.
AndroidSdkData data = AndroidSdkUtils.tryToChooseAndroidSdk();
SdkState.getInstance(data).loadAsync(SdkState.DEFAULT_EXPIRATION_PERIOD_MS, false, null, null, null, true);
}
示例4: testJdk7
import org.jetbrains.android.sdk.AndroidSdkUtils; //导入方法依赖的package包/类
public void testJdk7() throws Exception {
if (DISABLED) {
return;
}
AndroidSdkData sdkData = AndroidSdkUtils.tryToChooseAndroidSdk();
assertNotNull(sdkData);
if (ConfigureAndroidModuleStep.isJdk7Supported(sdkData)) {
IAndroidTarget[] targets = sdkData.getTargets();
IAndroidTarget target = targets[targets.length - 1];
Map<String,Object> overrides = Maps.newHashMap();
overrides.put(ATTR_JAVA_VERSION, "1.7");
NewProjectWizardState state = createNewProjectState(true, sdkData);
// TODO: Allow null activity state!
File activity = findTemplate("activities", "BlankActivity");
TemplateWizardState activityState = state.getActivityTemplateState();
assertNotNull(activity);
activityState.setTemplateLocation(activity);
checkApiTarget(19, 19, target, state, "Test17", null, overrides);
} else {
System.out.println("JDK 7 not supported by current SDK manager: not testing");
}
}
示例5: createComponent
import org.jetbrains.android.sdk.AndroidSdkUtils; //导入方法依赖的package包/类
@Nullable
@Override
public JComponent createComponent() {
AndroidSdkData data = AndroidSdkUtils.tryToChooseAndroidSdk();
if (data == null) {
JPanel errorPanel = new JPanel();
errorPanel.add(new JBLabel("Failed to find android sdk"));
return errorPanel;
}
final Runnable channelChangedCallback = new Runnable() {
@Override
public void run() {
boolean newIncludePreview =
SdkComponentSource.PREVIEW_CHANNEL.equals(UpdateSettings.getInstance().getExternalUpdateChannels().get(SdkComponentSource.NAME));
if (newIncludePreview != myIncludePreview) {
myIncludePreview = newIncludePreview;
myPanel.setIncludePreview(myIncludePreview);
}
}
};
SdkState state = SdkState.getInstance(data);
myPanel = new SdkUpdaterConfigPanel(state, channelChangedCallback);
JComponent component = myPanel.getComponent();
component.addAncestorListener(new AncestorListenerAdapter() {
@Override
public void ancestorAdded(AncestorEvent event) {
channelChangedCallback.run();
}
});
return myPanel.getComponent();
}
示例6: actionPerformed
import org.jetbrains.android.sdk.AndroidSdkUtils; //导入方法依赖的package包/类
@Override
public void actionPerformed(AnActionEvent e) {
if (ActionPlaces.WELCOME_SCREEN.equals(e.getPlace())) {
// Invoked from Welcome Screen, might not have an SDK setup yet
AndroidSdkData sdkData = AndroidSdkUtils.tryToChooseAndroidSdk();
if (sdkData != null) {
doRunTool(null, sdkData.getLocation().getPath());
}
}
else {
// Invoked from a project context
super.actionPerformed(e);
}
}
示例7: getTemplateRootFolder
import org.jetbrains.android.sdk.AndroidSdkUtils; //导入方法依赖的package包/类
/**
* @return the root folder containing templates
*/
@Nullable
public static File getTemplateRootFolder() {
String homePath = FileUtil.toSystemIndependentName(PathManager.getHomePath());
// Release build?
VirtualFile root = LocalFileSystem.getInstance().findFileByPath(FileUtil.toSystemIndependentName(homePath + BUNDLED_TEMPLATE_PATH));
if (root == null) {
// Development build?
for (String path : DEVELOPMENT_TEMPLATE_PATHS) {
root = LocalFileSystem.getInstance().findFileByPath(FileUtil.toSystemIndependentName(homePath + path));
if (root != null) {
break;
}
}
}
if (root != null) {
File rootFile = VfsUtilCore.virtualToIoFile(root);
if (templateRootIsValid(rootFile)) {
return rootFile;
}
}
// Fall back to SDK template root
AndroidSdkData sdkData = AndroidSdkUtils.tryToChooseAndroidSdk();
if (sdkData != null) {
File location = sdkData.getLocation();
File folder = new File(location, FD_TOOLS + File.separator + FD_TEMPLATES);
if (folder.isDirectory()) {
return folder;
}
}
return null;
}
示例8: getSkins
import org.jetbrains.android.sdk.AndroidSdkUtils; //导入方法依赖的package包/类
private static List<File> getSkins() {
List<Device> devices = DeviceManagerConnection.getDefaultDeviceManagerConnection().getDevices();
Set<File> result = Sets.newTreeSet();
for (Device device : devices) {
File skinFile = AvdEditWizard.resolveSkinPath(device.getDefaultHardware().getSkinFile(), null);
if (skinFile != null && skinFile.exists()) {
result.add(skinFile);
}
}
AndroidSdkData androidSdkData = AndroidSdkUtils.tryToChooseAndroidSdk();
LocalSdk mySdk = androidSdkData.getLocalSdk();
List<IAndroidTarget> targets = Lists.newArrayList(mySdk.getTargets());
for (IAndroidTarget target : targets) {
ISystemImage[] systemImages = target.getSystemImages();
if (systemImages != null) {
for (ISystemImage image : systemImages) {
SystemImageDescription desc = new SystemImageDescription(target, image);
for (File skin : desc.getSkins()) {
if (skin.exists()) {
result.add(skin);
}
}
}
}
}
List<File> resultList = Lists.newArrayList();
resultList.add(NO_SKIN);
resultList.addAll(result);
return resultList;
}
示例9: getDefaultAvdManagerConnection
import org.jetbrains.android.sdk.AndroidSdkUtils; //导入方法依赖的package包/类
@NotNull
public static AvdManagerConnection getDefaultAvdManagerConnection() {
AndroidSdkData androidSdkData = AndroidSdkUtils.tryToChooseAndroidSdk();
LocalSdk localSdk = null;
if (androidSdkData != null) {
localSdk = androidSdkData.getLocalSdk();
}
if (localSdk == null) {
return NULL_CONNECTION;
}
else {
return getAvdManagerConnection(localSdk);
}
}
示例10: getCompilationTargets
import org.jetbrains.android.sdk.AndroidSdkUtils; //导入方法依赖的package包/类
/**
* @return a list of android compilation targets (platforms and add-on SDKs)
*/
@NotNull
private static IAndroidTarget[] getCompilationTargets() {
AndroidSdkData sdkData = AndroidSdkUtils.tryToChooseAndroidSdk();
if (sdkData == null) {
return new IAndroidTarget[0];
}
return getCompilationTargets(sdkData);
}
示例11: putSdkDependentParams
import org.jetbrains.android.sdk.AndroidSdkUtils; //导入方法依赖的package包/类
public void putSdkDependentParams() {
final AndroidSdkData sdkData = AndroidSdkUtils.tryToChooseAndroidSdk();
BuildToolInfo buildTool = sdkData != null ? sdkData.getLatestBuildTool() : null;
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());
}
if (sdkData != null) {
// Gradle expects a platform-neutral path
put(ATTR_SDK_DIR, FileUtil.toSystemIndependentName(sdkData.getPath()));
}
}
示例12: LicenseAgreementStep
import org.jetbrains.android.sdk.AndroidSdkUtils; //导入方法依赖的package包/类
public LicenseAgreementStep(@NotNull Disposable disposable) {
super(disposable);
Splitter splitter = new Splitter(false, .30f);
splitter.setHonorComponentsMinimumSize(true);
myChangeTree = new Tree();
splitter.setFirstComponent(ScrollPaneFactory.createScrollPane(myChangeTree));
myLicenseTextField = new JTextPane();
splitter.setSecondComponent(ScrollPaneFactory.createScrollPane(myLicenseTextField));
myDeclineRadioButton = new JBRadioButton("Decline");
myAcceptRadioButton = new JBRadioButton("Accept");
ButtonGroup optionsGroup = new ButtonGroup();
optionsGroup.add(myDeclineRadioButton);
optionsGroup.add(myAcceptRadioButton);
JPanel optionsPanel = new JPanel(new FlowLayout(FlowLayout.TRAILING));
optionsPanel.add(myDeclineRadioButton);
optionsPanel.add(myAcceptRadioButton);
JPanel mainPanel = new JPanel(new BorderLayout());
mainPanel.add(splitter, BorderLayout.CENTER);
mainPanel.add(optionsPanel, BorderLayout.SOUTH);
setBodyComponent(mainPanel);
AndroidSdkData data = AndroidSdkUtils.tryToChooseAndroidSdk();
if (data != null) {
mySdkRoot = data.getLocalSdk().getLocation();
}
else {
mySdkRoot = null;
}
}
示例13: initState
import org.jetbrains.android.sdk.AndroidSdkUtils; //导入方法依赖的package包/类
/**
* Populate our state store with some common configuration items, such as the SDK location and the Gradle configuration.
*/
protected void initState() {
ScopedStateStore state = getState();
// TODO(jbakermalone): move the setting of this state closer to where it is used, so it's clear what's needed.
state.put(WizardConstants.GRADLE_VERSION_KEY, GRADLE_LATEST_VERSION);
state.put(WizardConstants.GRADLE_PLUGIN_VERSION_KEY, GRADLE_PLUGIN_RECOMMENDED_VERSION);
state.put(WizardConstants.USE_PER_MODULE_REPOS_KEY, false);
state.put(WizardConstants.IS_NEW_PROJECT_KEY, true);
state.put(WizardConstants.IS_GRADLE_PROJECT_KEY, true);
try {
state.put(WizardConstants.DEBUG_KEYSTORE_SHA_1_KEY, KeystoreUtils.sha1(KeystoreUtils.getOrCreateDefaultDebugKeystore()));
}
catch (Exception e) {
LOG.error("Could not create default debug keystore: " + e.getMessage());
state.put(WizardConstants.DEBUG_KEYSTORE_SHA_1_KEY, "");
}
AndroidSdkData sdkData = AndroidSdkUtils.tryToChooseAndroidSdk();
if (sdkData != null) {
state.put(WizardConstants.SDK_DIR_KEY, sdkData.getLocation().getPath());
}
String mavenUrl = System.getProperty(TemplateWizard.MAVEN_URL_PROPERTY);
if (mavenUrl != null) {
state.put(WizardConstants.MAVEN_URL_KEY, mavenUrl);
}
state.put(FILES_TO_OPEN_KEY, Lists.<File>newArrayList());
}
示例14: getSdkData
import org.jetbrains.android.sdk.AndroidSdkUtils; //导入方法依赖的package包/类
@Nullable
private AndroidSdkData getSdkData() {
AndroidSdkData sdkData = null;
if (myWizardContext != null) {
final Sdk projectJdk = myWizardContext.getProjectJdk();
if (projectJdk != null) {
sdkData = AndroidSdkData.getSdkData(projectJdk);
}
}
if (sdkData == null) {
sdkData = AndroidSdkUtils.tryToChooseAndroidSdk();
}
return sdkData;
}
示例15: initState
import org.jetbrains.android.sdk.AndroidSdkUtils; //导入方法依赖的package包/类
/**
* Populate our state store with some common configuration items, such as the SDK location and the Gradle configuration.
*/
protected void initState() {
ScopedStateStore state = getState();
// TODO(jbakermalone): move the setting of this state closer to where it is used, so it's clear what's needed.
state.put(WizardConstants.GRADLE_VERSION_KEY, GRADLE_LATEST_VERSION);
state.put(WizardConstants.GRADLE_PLUGIN_VERSION_KEY, GRADLE_PLUGIN_RECOMMENDED_VERSION);
state.put(WizardConstants.USE_PER_MODULE_REPOS_KEY, false);
state.put(WizardConstants.IS_NEW_PROJECT_KEY, true);
state.put(WizardConstants.IS_GRADLE_PROJECT_KEY, true);
try {
state.put(WizardConstants.DEBUG_KEYSTORE_SHA_1_KEY, KeystoreUtils.sha1(KeystoreUtils.getOrCreateDefaultDebugKeystore()));
}
catch (Exception e) {
LOG.error("Could not create default debug keystore: " + e.getMessage());
state.put(WizardConstants.DEBUG_KEYSTORE_SHA_1_KEY, "");
}
AndroidSdkData sdkData = AndroidSdkUtils.tryToChooseAndroidSdk();
if (sdkData != null) {
state.put(WizardConstants.SDK_DIR_KEY, sdkData.getLocation().getPath());
}
String mavenUrl = System.getProperty(TemplateWizard.MAVEN_URL_PROPERTY);
if (mavenUrl != null) {
state.put(WizardConstants.MAVEN_URL_KEY, mavenUrl);
}
Project project = getProject();
if (project != null) {
state.put(PROJECT_LOCATION_KEY, project.getBasePath());
}
state.put(FILES_TO_OPEN_KEY, Lists.<File>newArrayList());
}