Class PlatformTarget
- java.lang.Object
-
- com.android.sdklib.repository.targets.PlatformTarget
-
- All Implemented Interfaces:
IAndroidTarget,java.lang.Comparable<IAndroidTarget>
public class PlatformTarget extends java.lang.Object implements IAndroidTarget
Represents a platform target in the SDK.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classPlatformTarget.LibrarySimple struct used byGsonwhen parsing the library file.
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringPLATFORM_VENDORDefault vendor for platform targets-
Fields inherited from interface com.android.sdklib.IAndroidTarget
ACTIONS_ACTIVITY, ACTIONS_BROADCAST, ACTIONS_SERVICE, ANDROID_AIDL, ANDROID_JAR, ANT, ATTRIBUTES, CATEGORIES, CORE_FOR_SYSTEM_MODULES_JAR, DATA, DOCS, FONTS, LAYOUT_LIB, MANIFEST_ATTRIBUTES, RESOURCES, SAMPLES, SKINS, SOURCES, TEMPLATES, UI_AUTOMATOR_JAR, WIDGETS
-
-
Constructor Summary
Constructors Constructor Description PlatformTarget(com.android.repository.api.LocalPackage p, AndroidSdkHandler sdkHandler, com.android.repository.api.ProgressIndicator progress)Construct a newPlatformTargetbased on the given package.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancanRunOn(IAndroidTarget target)Returns whether the given target is compatible with the receiver.intcompareTo(IAndroidTarget o)booleanequals(java.lang.Object obj)java.util.List<OptionalLibrary>getAdditionalLibraries()Returns the additional libraries for this target.java.util.List<java.lang.String>getBootClasspath()Returns the boot classpath for this target.BuildToolInfogetBuildToolInfo()Returns a BuildToolInfo for backward compatibility.java.lang.StringgetClasspathName()Returns the name to be displayed when representing all the libraries this target contains.java.nio.file.PathgetDefaultSkin()Returns the default skin folder for this target.java.lang.StringgetFullName()Returns the full name of the target, possibly including vendor name.intgetLayoutlibApi()static java.util.List<OptionalLibrary>getLibsFromJson(java.nio.file.Path jsonFile)ParsesOptionalLibrarys from the given json file.java.lang.StringgetLocation()Returns the target location, including a trailing file separator.java.lang.StringgetName()Returns the name of the target.java.util.List<OptionalLibrary>getOptionalLibraries()Returns a list of optional libraries for this target.IAndroidTargetgetParent()Returns the parent target.java.nio.file.PathgetPath(int pathId)Returns the path of a platform component.java.lang.String[]getPlatformLibraries()Returns the list of libraries available for a given platform.java.util.Map<java.lang.String,java.lang.String>getProperties()Returns all the properties associated with this target.java.lang.StringgetProperty(java.lang.String name)Return the value of a given property for this target.intgetRevision()Returns the revision number for the target.java.lang.StringgetShortClasspathName()Returns the name to be displayed when representing all the libraries this target contains.java.nio.file.Path[]getSkins()Returns the available skin folders for this target.java.lang.StringgetVendor()Returns the name of the vendor of the target.com.android.sdklib.AndroidVersiongetVersion()Returns the version of the target.java.lang.StringgetVersionName()Returns the platform version as a readable string.inthashCode()java.lang.StringhashString()Returns a string able to uniquely identify a target.booleanhasRenderingLibrary()Returns whether the target is able to render layouts.booleanisPlatform()Returns true if the target is a standard Android platform.voidsetSources(java.nio.file.Path location)
-
-
-
Field Detail
-
PLATFORM_VENDOR
public static final java.lang.String PLATFORM_VENDOR
Default vendor for platform targets- See Also:
- Constant Field Values
-
-
Constructor Detail
-
PlatformTarget
public PlatformTarget(@NonNull com.android.repository.api.LocalPackage p, @NonNull AndroidSdkHandler sdkHandler, @NonNull com.android.repository.api.ProgressIndicator progress)Construct a newPlatformTargetbased on the given package.
-
-
Method Detail
-
setSources
public void setSources(@Nullable java.nio.file.Path location)
-
getLibsFromJson
@NonNull public static java.util.List<OptionalLibrary> getLibsFromJson(@NonNull java.nio.file.Path jsonFile)
ParsesOptionalLibrarys from the given json file.
-
getLocation
@NonNull public java.lang.String getLocation()
Description copied from interface:IAndroidTargetReturns the target location, including a trailing file separator.- Specified by:
getLocationin interfaceIAndroidTarget
-
getVendor
public java.lang.String getVendor()
Returns the name of the vendor of the target. For platform, this is alwaysPLATFORM_VENDOR- Specified by:
getVendorin interfaceIAndroidTarget
-
getName
public java.lang.String getName()
Description copied from interface:IAndroidTargetReturns the name of the target.- Specified by:
getNamein interfaceIAndroidTarget
-
getFullName
public java.lang.String getFullName()
Description copied from interface:IAndroidTargetReturns the full name of the target, possibly including vendor name.- Specified by:
getFullNamein interfaceIAndroidTarget
-
getVersion
@NonNull public com.android.sdklib.AndroidVersion getVersion()
Description copied from interface:IAndroidTargetReturns the version of the target. This is guaranteed to be non-null.- Specified by:
getVersionin interfaceIAndroidTarget
-
getVersionName
public java.lang.String getVersionName()
Description copied from interface:IAndroidTargetReturns the platform version as a readable string.- Specified by:
getVersionNamein interfaceIAndroidTarget
-
getRevision
public int getRevision()
Description copied from interface:IAndroidTargetReturns the revision number for the target.- Specified by:
getRevisionin interfaceIAndroidTarget
-
isPlatform
public boolean isPlatform()
Description copied from interface:IAndroidTargetReturns true if the target is a standard Android platform.- Specified by:
isPlatformin interfaceIAndroidTarget
-
getParent
@Nullable public IAndroidTarget getParent()
Description copied from interface:IAndroidTargetReturns the parent target. This is likely to only be nonnullifIAndroidTarget.isPlatform()returnsfalse- Specified by:
getParentin interfaceIAndroidTarget
-
getPath
@NonNull public java.nio.file.Path getPath(int pathId)
Description copied from interface:IAndroidTargetReturns the path of a platform component.- Specified by:
getPathin interfaceIAndroidTarget- Parameters:
pathId- the id representing the path to return. Any of the constants defined in theIAndroidTargetinterface can be used.
-
getBuildToolInfo
@Nullable public BuildToolInfo getBuildToolInfo()
Description copied from interface:IAndroidTargetReturns a BuildToolInfo for backward compatibility. If an older SDK is used this will return paths located in the platform-tools, otherwise it'll return paths located in the latest build-tools.- Specified by:
getBuildToolInfoin interfaceIAndroidTarget- Returns:
- a BuildToolInfo or null if none are available.
-
getBootClasspath
@NonNull public java.util.List<java.lang.String> getBootClasspath()
Description copied from interface:IAndroidTargetReturns the boot classpath for this target. In most case, this is similar to callingIAndroidTarget.getPath(int)withIAndroidTarget.ANDROID_JAR.- Specified by:
getBootClasspathin interfaceIAndroidTarget- Returns:
- a non null list of the boot classpath.
-
getOptionalLibraries
@NonNull public java.util.List<OptionalLibrary> getOptionalLibraries()
Description copied from interface:IAndroidTargetReturns a list of optional libraries for this target.These libraries are not automatically added to the classpath. Using them requires adding a
uses-libraryentry in the manifest and callinguseLibraryin the Gradle build script. Example of such library isorg.apache.http.legacywhich is not on the classpath by default since 6.0.- Specified by:
getOptionalLibrariesin interfaceIAndroidTarget- Returns:
- a list of libraries.
- See Also:
OptionalLibrary.getName()
-
getAdditionalLibraries
@NonNull public java.util.List<OptionalLibrary> getAdditionalLibraries()
Description copied from interface:IAndroidTargetReturns the additional libraries for this target.These libraries are automatically added to the classpath, but using them requires adding a
uses-libraryentry in the manifest. Example of such library iscom.google.android.maps, which is part of the Google APIs add-on.- Specified by:
getAdditionalLibrariesin interfaceIAndroidTarget- Returns:
- a list of libraries.
- See Also:
OptionalLibrary.getName()
-
hasRenderingLibrary
public boolean hasRenderingLibrary()
Description copied from interface:IAndroidTargetReturns whether the target is able to render layouts.- Specified by:
hasRenderingLibraryin interfaceIAndroidTarget
-
getSkins
@NonNull public java.nio.file.Path[] getSkins()
Description copied from interface:IAndroidTargetReturns the available skin folders for this target.To get the skin names, use
File.getName().
Skins come either from:- a platform (
sdk/platforms/N/skins/name) - an add-on (
sdk/addons/name/skins/name) - a tagged system-image (
sdk/system-images/platform-N/tag/abi/skins/name.)
- Specified by:
getSkinsin interfaceIAndroidTarget
- a platform (
-
getLayoutlibApi
public int getLayoutlibApi()
-
getDefaultSkin
@Nullable public java.nio.file.Path getDefaultSkin()
Description copied from interface:IAndroidTargetReturns the default skin folder for this target.To get the skin name, use
File.getName().- Specified by:
getDefaultSkinin interfaceIAndroidTarget
-
getPlatformLibraries
@NonNull public java.lang.String[] getPlatformLibraries()
Returns the list of libraries available for a given platform. For platforms this is alwaysSdkConstants.ANDROID_TEST_RUNNER_LIB.- Specified by:
getPlatformLibrariesin interfaceIAndroidTarget- Returns:
- an array of libraries provided by the platform or
nullif there is none.
-
getProperty
@Nullable public java.lang.String getProperty(@NonNull java.lang.String name)Description copied from interface:IAndroidTargetReturn the value of a given property for this target.- Specified by:
getPropertyin interfaceIAndroidTarget- Returns:
- the property value or
nullif it was not found.
-
getProperties
@Nullable public java.util.Map<java.lang.String,java.lang.String> getProperties()
Description copied from interface:IAndroidTargetReturns all the properties associated with this target. This can be null if the target has no properties.- Specified by:
getPropertiesin interfaceIAndroidTarget
-
getShortClasspathName
@NonNull public java.lang.String getShortClasspathName()
Description copied from interface:IAndroidTargetReturns the name to be displayed when representing all the libraries this target contains.- Specified by:
getShortClasspathNamein interfaceIAndroidTarget
-
getClasspathName
@NonNull public java.lang.String getClasspathName()
Description copied from interface:IAndroidTargetReturns the name to be displayed when representing all the libraries this target contains.- Specified by:
getClasspathNamein interfaceIAndroidTarget
-
canRunOn
public boolean canRunOn(@NonNull IAndroidTarget target)Description copied from interface:IAndroidTargetReturns whether the given target is compatible with the receiver.This means that a project using the receiver's target can run on the given target.
Example:CupcakeTarget.canRunOn(DonutTarget) == true
.- Specified by:
canRunOnin interfaceIAndroidTarget- Parameters:
target- the IAndroidTarget to test.
-
hashString
@NonNull public java.lang.String hashString()
Description copied from interface:IAndroidTargetReturns a string able to uniquely identify a target. Typically the target will encode information such as api level, whether it's a platform or add-on, and if it's an add-on vendor and add-on name.See
AndroidTargetHashfor helper methods to manipulate hash strings.- Specified by:
hashStringin interfaceIAndroidTarget
-
compareTo
public int compareTo(@NonNull IAndroidTarget o)- Specified by:
compareToin interfacejava.lang.Comparable<IAndroidTarget>
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
-