use of com.android.sdklib.IAndroidTarget in project otertool by wuntee.
the class AvdWorkshop method createAvd.
public static AvdInfo createAvd(CreateAvdBean bean) throws AndroidLocationException, IOException, GenericException {
ISdkLog sdkLogger = AvdWorkshop.getAvdLogger();
SdkManager sdkManager = SdkManager.createManager(OterStatics.getAndroidHome(), sdkLogger);
AvdManager avdManager = new AvdManager(sdkManager, sdkLogger);
File avdFolder = new File(AndroidLocation.getFolder() + "avd", bean.getName() + ".avd");
//newAvdInfo = avdManager.createAvd(avdFolder, avdName, target, skin, this.mSdkCommandLine.getParamSdCard(), hardwareConfig, removePrevious, this.mSdkCommandLine.getFlagSnapshot(), this.mSdkLog);
IAndroidTarget target = getAndroidTargetFromString(sdkManager, bean.getTarget());
ISystemImage[] abiTypes = target.getSystemImages();
if (abiTypes.length == 0) {
throw new GenericException("There are no images associated with the target.");
}
//ABI = Android Base Image ?
String abiType = abiTypes[0].getAbiType();
// /Applications/android-sdk-macosx/system-images/android-15/armeabi-v7a//system.img
// avdManager. createAvd(avdFolder, avdName, avdTarget, ABI, skin, sdCard, hadwareConfig, snapshot, force, false, logger)
//AvdInfo ret = avdManager.createAvd(avdFolder, bean.getName(), target, null, null, null, false, false, sdkLogger);
// createAvd(File arg0, String arg1, IAndroidTarget arg2, String arg3, String arg4, Map<String, String> arg5, boolean arg6, boolean arg7, ISdkLog arg8)
AvdInfo ret = avdManager.createAvd(avdFolder, bean.getName(), target, abiType, null, null, null, false, false, false, sdkLogger);
if (ret == null) {
logger.error("There was an error createing AVD, the manager returned a null info object.");
throw new GenericException("Could not create AVD for an unknown reason.");
}
if (bean.isPersistant() == true) {
makeAvdPersistant(ret);
}
return (ret);
}
use of com.android.sdklib.IAndroidTarget in project kotlin by JetBrains.
the class LintClient method getTargets.
/**
* Returns all the {@link IAndroidTarget} versions installed in the user's SDK install
* area.
*
* @return all the installed targets
*/
@NonNull
public IAndroidTarget[] getTargets() {
if (mTargets == null) {
AndroidSdkHandler sdkHandler = getSdk();
if (sdkHandler != null) {
ProgressIndicator logger = getRepositoryLogger();
Collection<IAndroidTarget> targets = sdkHandler.getAndroidTargetManager(logger).getTargets(logger);
mTargets = targets.toArray(new IAndroidTarget[targets.size()]);
} else {
mTargets = new IAndroidTarget[0];
}
}
return mTargets;
}
use of com.android.sdklib.IAndroidTarget in project kotlin by JetBrains.
the class LintClient method getCompileTarget.
/**
* Returns the compile target to use for the given project
*
* @param project the project in question
*
* @return the compile target to use to build the given project
*/
@Nullable
public IAndroidTarget getCompileTarget(@NonNull Project project) {
int buildSdk = project.getBuildSdk();
IAndroidTarget[] targets = getTargets();
for (int i = targets.length - 1; i >= 0; i--) {
IAndroidTarget target = targets[i];
if (target.isPlatform() && target.getVersion().getApiLevel() == buildSdk) {
return target;
}
}
return null;
}
use of com.android.sdklib.IAndroidTarget in project kotlin by JetBrains.
the class Project method readManifest.
/**
* Initialized the manifest state from the given manifest model
*
* @param document the DOM document for the manifest XML document
*/
public void readManifest(@NonNull Document document) {
Element root = document.getDocumentElement();
if (root == null) {
return;
}
mPackage = root.getAttribute(ATTR_PACKAGE);
// shouldn't have to investigate)
if (mPackage != null && mPackage.startsWith("android.support.")) {
mReportIssues = false;
}
// Initialize minSdk and targetSdk
mManifestMinSdk = AndroidVersion.DEFAULT;
mManifestTargetSdk = AndroidVersion.DEFAULT;
NodeList usesSdks = root.getElementsByTagName(TAG_USES_SDK);
if (usesSdks.getLength() > 0) {
Element element = (Element) usesSdks.item(0);
String minSdk = null;
if (element.hasAttributeNS(ANDROID_URI, ATTR_MIN_SDK_VERSION)) {
minSdk = element.getAttributeNS(ANDROID_URI, ATTR_MIN_SDK_VERSION);
}
if (minSdk != null) {
IAndroidTarget[] targets = mClient.getTargets();
mManifestMinSdk = SdkVersionInfo.getVersion(minSdk, targets);
}
if (element.hasAttributeNS(ANDROID_URI, ATTR_TARGET_SDK_VERSION)) {
String targetSdk = element.getAttributeNS(ANDROID_URI, ATTR_TARGET_SDK_VERSION);
if (targetSdk != null) {
IAndroidTarget[] targets = mClient.getTargets();
mManifestTargetSdk = SdkVersionInfo.getVersion(targetSdk, targets);
}
} else {
mManifestTargetSdk = mManifestMinSdk;
}
} else if (isAospBuildEnvironment()) {
extractAospMinSdkVersion();
mManifestTargetSdk = mManifestMinSdk;
}
}
use of com.android.sdklib.IAndroidTarget in project android by JetBrains.
the class TemplateTest method testJdk5.
public void testJdk5() throws Exception {
if (DISABLED) {
return;
}
AndroidSdkData sdkData = AndroidSdks.getInstance().tryToChooseAndroidSdk();
assertNotNull(sdkData);
IAndroidTarget[] targets = sdkData.getTargets();
IAndroidTarget target = targets[targets.length - 1];
Map<String, Object> overrides = new HashMap<>();
overrides.put(ATTR_JAVA_VERSION, "1.5");
NewProjectWizardState state = createNewProjectState(true, sdkData);
// TODO: Allow null activity state!
File activity = findTemplate("activities", "BasicActivity");
TemplateWizardState activityState = state.getActivityTemplateState();
assertNotNull(activity);
activityState.setTemplateLocation(activity);
checkApiTarget(9, 18, target, state, "Test15", null, overrides, null);
}
Aggregations