Package com.android.sdklib
Class SdkVersionInfo
- java.lang.Object
-
- com.android.sdklib.SdkVersionInfo
-
public class SdkVersionInfo extends java.lang.ObjectInformation about available SDK Versions
-
-
Field Summary
Fields Modifier and Type Field Description static intCUR_DEVELOPMENTBuild.VERSION_CODES.CUR_DEVELOPMENT; set for platforms in development before previewstatic intHIGHEST_KNOWN_APIThe highest known API level.static intHIGHEST_KNOWN_API_TVThe highest known API level for Android TV.static intHIGHEST_KNOWN_API_WEARThe highest known API level for Wearables.static intHIGHEST_KNOWN_STABLE_APILikeHIGHEST_KNOWN_APIbut does not include preview platforms.static intLOWEST_ACTIVE_APIThe lowest active API level in the ecosystem.static intLOWEST_ACTIVE_API_TVThe lowest active api for TV.static intLOWEST_ACTIVE_API_WEARThe lowest active api for wearables.static intLOWEST_COMPILE_SDK_VERSIONThe lowest api level we can accept for compileSdkVersion for for a new project.static intRECOMMENDED_MIN_SDK_VERSIONThe default minSdkVersion to use for new projects and modules.
-
Constructor Summary
Constructors Constructor Description SdkVersionInfo()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.StringcamelCaseToUnderlines(java.lang.String string)Converts a CamelCase word into an underlined_wordstatic java.lang.StringgetAndroidName(int api)Returns the Android version and code name of the given API level The highest number (inclusive) that is supported isHIGHEST_KNOWN_API.static java.lang.StringgetAndroidVersionCodeName(com.android.sdklib.AndroidVersion version)Returns the codename for a givenAndroidVersion's API level.static intgetApiByBuildCode(java.lang.String buildCode, boolean recognizeUnknowns)Returns the API level of the given build code (e.g.static intgetApiByPreviewName(java.lang.String previewName, boolean recognizeUnknowns)Returns the API level of the given preview code name (e.g.static java.lang.StringgetBuildCode(int api)Returns the applicable build code (forandroid.os.Build.VERSION_CODES) for the corresponding API level, or null if it's unknown.static java.lang.StringgetCodeName(int api)static com.android.sdklib.AndroidVersiongetVersion(java.lang.String apiOrPreviewName, IAndroidTarget[] targets)Returns theAndroidVersionfor a given version string, which is typically an API level number, but can also be a codename for a preview platform.static java.lang.StringgetVersionString(int api)static java.lang.StringgetVersionStringSanitized(int api)static java.lang.StringgetVersionWithCodename(com.android.sdklib.AndroidVersion version)Returns a user-friendly description of this version, like "Android 5.1 (Lollipop)", or "Android 6.X (N) Preview".static java.lang.StringunderlinesToCamelCase(java.lang.String string)Converts an underlined_word into a CamelCase word
-
-
-
Field Detail
-
HIGHEST_KNOWN_API
public static final int HIGHEST_KNOWN_API
The highest known API level. Note that the tools may also look at the installed platforms to see if they can find more recently released platforms, e.g. when the tools have not yet been updated for a new release. This number is used as a baseline and any more recent platforms found can be used to increase the highest known number.- See Also:
- Constant Field Values
-
HIGHEST_KNOWN_STABLE_API
public static final int HIGHEST_KNOWN_STABLE_API
LikeHIGHEST_KNOWN_APIbut does not include preview platforms.Make sure to keep this in sync with the value in TestUtils.
- See Also:
- Constant Field Values
-
LOWEST_ACTIVE_API
public static final int LOWEST_ACTIVE_API
The lowest active API level in the ecosystem. This number will change over time as the distribution of older platforms decreases.- See Also:
- Constant Field Values
-
RECOMMENDED_MIN_SDK_VERSION
public static final int RECOMMENDED_MIN_SDK_VERSION
The default minSdkVersion to use for new projects and modules. This number is going to be at leastLOWEST_ACTIVE_API, but can often be higher;LOWEST_ACTIVE_APIis the minimum supported API level, whereas this constant is the recommended minSdkVersion.- See Also:
- Constant Field Values
-
HIGHEST_KNOWN_API_WEAR
public static final int HIGHEST_KNOWN_API_WEAR
The highest known API level for Wearables. Note the tools at the downloadable system images for wearables to see if there are more recent versions.- See Also:
- Constant Field Values
-
LOWEST_ACTIVE_API_WEAR
public static final int LOWEST_ACTIVE_API_WEAR
The lowest active api for wearables. This number will change over time as the distribution of older platforms decreases.- See Also:
- Constant Field Values
-
HIGHEST_KNOWN_API_TV
public static final int HIGHEST_KNOWN_API_TV
The highest known API level for Android TV. Note the tools at the downloadable system images for TV to see if there are more recent versions.- See Also:
- Constant Field Values
-
LOWEST_ACTIVE_API_TV
public static final int LOWEST_ACTIVE_API_TV
The lowest active api for TV. This number will change over time as the distribution of older platforms decreases.- See Also:
- Constant Field Values
-
LOWEST_COMPILE_SDK_VERSION
public static final int LOWEST_COMPILE_SDK_VERSION
The lowest api level we can accept for compileSdkVersion for for a new project. Make sure design and appcompat is supported.- See Also:
- Constant Field Values
-
CUR_DEVELOPMENT
public static final int CUR_DEVELOPMENT
Build.VERSION_CODES.CUR_DEVELOPMENT; set for platforms in development before preview- See Also:
- Constant Field Values
-
-
Method Detail
-
getAndroidName
@NonNull public static java.lang.String getAndroidName(int api)
Returns the Android version and code name of the given API level The highest number (inclusive) that is supported isHIGHEST_KNOWN_API.- Parameters:
api- the api level- Returns:
- a suitable version display name
-
getVersionStringSanitized
@NonNull public static java.lang.String getVersionStringSanitized(int api)
-
getVersionString
@Nullable public static java.lang.String getVersionString(int api)
-
getCodeName
@Nullable public static java.lang.String getCodeName(int api)
-
getBuildCode
@Nullable public static java.lang.String getBuildCode(int api)
Returns the applicable build code (forandroid.os.Build.VERSION_CODES) for the corresponding API level, or null if it's unknown. The highest number (inclusive) that is supported isHIGHEST_KNOWN_API.- Parameters:
api- the API level to look up a version code for- Returns:
- the corresponding build code field name, or null
-
getApiByBuildCode
public static int getApiByBuildCode(@NonNull java.lang.String buildCode, boolean recognizeUnknowns)Returns the API level of the given build code (e.g. JELLY_BEAN_MR1 ⇒ 17), or -1 if not recognized- Parameters:
buildCode- the build code name (not case sensitive)recognizeUnknowns- if true, treat an unrecognized code name as a newly released platform the tools are not yet aware of, and set its API level to some higher number than all the currently known API versions- Returns:
- the API level, or -1 if not recognized (unless recognizeUnknowns is true, in which
HIGHEST_KNOWN_APIplus one is returned
-
getApiByPreviewName
public static int getApiByPreviewName(@NonNull java.lang.String previewName, boolean recognizeUnknowns)Returns the API level of the given preview code name (e.g. JellyBeanMR2 ⇒ 17), or -1 if not recognized- Parameters:
previewName- the preview name (not case sensitive)recognizeUnknowns- if true, treat an unrecognized code name as a newly released platform the tools are not yet aware of, and set its API level to some higher number than all the currently known API versions- Returns:
- the API level, or -1 if not recognized (unless recognizeUnknowns is true, in which
HIGHEST_KNOWN_APIplus one is returned
-
camelCaseToUnderlines
@NonNull public static java.lang.String camelCaseToUnderlines(@NonNull java.lang.String string)Converts a CamelCase word into an underlined_word- Parameters:
string- the CamelCase version of the word- Returns:
- the underlined version of the word
-
underlinesToCamelCase
@NonNull public static java.lang.String underlinesToCamelCase(@NonNull java.lang.String string)Converts an underlined_word into a CamelCase word- Parameters:
string- the underlined word to convert- Returns:
- the CamelCase version of the word
-
getVersion
@Nullable public static com.android.sdklib.AndroidVersion getVersion(@Nullable java.lang.String apiOrPreviewName, @Nullable IAndroidTarget[] targets)Returns theAndroidVersionfor a given version string, which is typically an API level number, but can also be a codename for a preview platform. Note: This should not be used to look up version names for build codes; for that, usegetApiByBuildCode(String, boolean). The primary difference between this method is thatgetApiByBuildCode(String, boolean)will return the final API number for a platform (e.g. for "KITKAT" it will return 19) whereas this method will return the API number for the codename as a preview platform (e.g. 18).- Parameters:
apiOrPreviewName- the version stringtargets- an optional array of installed targets, if available. If the version string corresponds to a code name, this is used to search for a corresponding API level.- Returns:
- an
AndroidVersion, or null if the version could not be determined (e.g. an empty or invalid API number or an unknown code name)
-
getAndroidVersionCodeName
@Nullable public static java.lang.String getAndroidVersionCodeName(@NonNull com.android.sdklib.AndroidVersion version)Returns the codename for a givenAndroidVersion's API level.
-
getVersionWithCodename
public static java.lang.String getVersionWithCodename(com.android.sdklib.AndroidVersion version)
Returns a user-friendly description of this version, like "Android 5.1 (Lollipop)", or "Android 6.X (N) Preview".
-
-