use of com.android.sdklib.AndroidVersion in project android by JetBrains.
the class ImportModule method getLatestVersion.
@Nullable
public GradleCoordinate getLatestVersion(String artifact) {
int compileVersion = GradleImport.CURRENT_COMPILE_VERSION;
AndroidVersion version = getCompileSdkVersion();
if (version != AndroidVersion.DEFAULT) {
compileVersion = version.getFeatureLevel();
}
// from version 18 (earliest version where we have all the libs in the m2 repository)
if (compileVersion < 18) {
compileVersion = 18;
}
String compileVersionString = Integer.toString(compileVersion);
if (myImporter.getSdkLocation() != null) {
@SuppressWarnings("UnnecessaryLocalVariable") String filter = compileVersionString;
GradleCoordinate max = SdkMavenRepository.ANDROID.getHighestInstalledVersion(myImporter.getSdkLocation(), SUPPORT_GROUP_ID, artifact, filter, true);
if (max != null) {
return max;
}
}
String coordinate = SUPPORT_GROUP_ID + ':' + artifact + ':' + compileVersionString + ".+";
return GradleCoordinate.parseCoordinateString(coordinate);
}
use of com.android.sdklib.AndroidVersion in project android by JetBrains.
the class JdkModuleSetupStep method setUpInAndroidStudio.
@VisibleForTesting
void setUpInAndroidStudio(@NotNull Module module, @NotNull AndroidModuleModel androidModel) {
AndroidProject androidProject = androidModel.getAndroidProject();
String compileTarget = androidProject.getCompileTarget();
AndroidVersion version = AndroidTargetHash.getPlatformVersion(compileTarget);
if (version != null && version.getFeatureLevel() >= 21) {
Sdk jdk = myIdeSdks.getJdk();
if (jdk != null && !myJdks.isApplicableJdk(jdk, JDK_1_7)) {
Project project = module.getProject();
SyncMessage msg;
String text = "compileSdkVersion " + compileTarget + " requires compiling with JDK 7 or newer.";
VirtualFile buildFile = getGradleBuildFile(module);
if (buildFile != null) {
msg = reportWrongJdkError(project, text, buildFile);
} else {
msg = reportWrongJdkError(project, text);
}
SyncMessages.getInstance(project).report(msg);
GradleSyncState.getInstance(project).getSummary().setWrongJdkFound(true);
}
}
}
use of com.android.sdklib.AndroidVersion in project android by JetBrains.
the class AndroidLintOldTargetApiInspection method getHighestApi.
private static int getHighestApi(PsiElement element) {
int max = SdkVersionInfo.HIGHEST_KNOWN_STABLE_API;
AndroidFacet instance = AndroidFacet.getInstance(element);
if (instance != null) {
AndroidSdkData sdkData = instance.getSdkData();
if (sdkData != null) {
for (IAndroidTarget target : sdkData.getTargets()) {
if (target.isPlatform()) {
AndroidVersion version = target.getVersion();
if (version.getApiLevel() > max && !version.isPreview()) {
max = version.getApiLevel();
}
}
}
}
}
return max;
}
use of com.android.sdklib.AndroidVersion in project android by JetBrains.
the class IdeSdks method doesIdeAndroidSdkExist.
/**
* @return {@code true} if an IntelliJ SDK with the default naming convention already exists for the given Android build target.
*/
private boolean doesIdeAndroidSdkExist(@NotNull IAndroidTarget target) {
for (Sdk sdk : getEligibleAndroidSdks()) {
IAndroidTarget platformTarget = getTarget(sdk);
AndroidVersion version = target.getVersion();
AndroidVersion existingVersion = platformTarget.getVersion();
if (existingVersion.equals(version)) {
return true;
}
}
return false;
}
use of com.android.sdklib.AndroidVersion in project android by JetBrains.
the class AndroidDrawableDomUtil method getPossibleRoots.
public static List<String> getPossibleRoots(AndroidFacet facet) {
AndroidVersion sdkVersion = AndroidModuleInfo.get(facet).getBuildSdkVersion();
List<String> result = Lists.newArrayListWithExpectedSize(DRAWABLE_ROOTS_V1.length + DRAWABLE_ROOTS_V21.length);
Collections.addAll(result, DRAWABLE_ROOTS_V1);
if (sdkVersion == null || sdkVersion.getFeatureLevel() >= 21 || ApplicationManager.getApplication().isUnitTestMode()) {
Collections.addAll(result, DRAWABLE_ROOTS_V21);
}
return result;
}
Aggregations